1.Which identifiers are valid? a) _xpoints b) r2d2 c) bBb$ d) set-flow e) thisisCrazy I choose b,c,e ,but supply my answer to website,it show error 2.If you want subclasses to access, but not to override a superclass member method, what keyword should precede the name of the superclass method? fill the keyword: I fill "super",but failed 3. For what reasons might a thread stop execution? a) A thread with higher priority began execution. b) The thread's wait() method was invoked. c) The thread invoked its yield() method. d) The thread's pause() method was invoked. e) The thread's sleep() method was invoked. I choose a,c but failed 4. Which of the following describe the sequence of method calls that result in a component being redrawn? a) invoke paint() directly b) invoke update which calls paint() c) invoke repaint() which invokes update(), which in turn invokes paint() d) invoke repaint() which invokes paint directly I choose a,d but failed Who can tell me the correct answer,and why? thanks
Rashmi Tambe
Ranch Hand
Joined: Aug 07, 2001
Posts: 418
posted
0
Hi, 1) correct answer is a,b,c,e. _ is a valid character to start an identifier 2)If u want a subclass to access and not override its method then use final and not super. super is like a reference to the super class. 3)For option a. it is platform dependant. If higher priority threads comes some scheduler may stop currently running thread. option b. - wait() causes the thread to wait in object lock pool till the object's monitor is made available to it. option c.- thread calling yield() may give a chance to another thread to run option d.- there is no such method. option e.- sleep definately stops the thread The so correct options are a,b,c,e 4.correct option is c ie. invoke repaint() which invokes update(), which in turn invokes paint() paint cant be called directly and repaint() does not call paint() directly , it calls update(). HOPE this helps Rashmi
Rashid Ali
Ranch Hand
Joined: Jan 16, 2001
Posts: 349
posted
0
Correct answer are as under: 1. a, b, c and e ( under_socre is also allowed) 2. i think the word 'final' is applicable here 3. i think a, b, c and e are right 4. i am not confirmed for these answers Hope above suffice your querry. Please post only 1 question per mail. this will reduce the complexity of reader. Good luck Rashid Ali PS: the above post conflicts with my mail. Same time posting of the both mail [ January 15, 2002: Message edited by: Rashid Ali ]
Rashid Ali
Ranch Hand
Joined: Jan 16, 2001
Posts: 349
posted
0
Dear qunlbao, Please re-register yourself with your full name (at least 2 words). This is as per JavaRanch policy which is applied to every member here. And you will have to re-register for this purpose cuz you cannot change your member name after it's created. Thanks and wish you good luck. Rashid Ali
Valentin Crettaz
Gold Digger
Sheriff
Joined: Aug 26, 2001
Posts: 7610
posted
0
qunlbao, Please read the Javaranch Naming Policy and register again. Thank you for your cooperation.
2、private Private method in super class can not be overriden by subclass,and private method do exist in subclass Am I right?
Shivaji Marathe
Ranch Hand
Joined: Jan 11, 2002
Posts: 203
posted
0
Andrew : private wont work as an answer for Q2 above. A private method can not be accessed by any class except the class in which it is declared. So if you have class Parent with a private method aMethod(), then class Child which extends parent can not call aMethod() or super.aMethod() or Parent.aMethod(). Final is the correct answer for this question.
Jose Botella
Ranch Hand
Joined: Jul 03, 2001
Posts: 2120
posted
0
I�m not happy with 3 b) because it is not the thread �wait method, the one to call; but the wait method on the monitor that protects the code in which wait appear:
synchronized(monitor) { try { monitor.wait(); } catch(InterruptedException ie) {} } this runs ok and we are calling wait on the monitor not on the thread object. If you don't follow this rule and call wait on the thread that is executing the code IllegalMonitorStateException is thrown (unless the monitor of the thread happens to be used)
SCJP2. Please Indent your code using UBB Code
Deepti Dixit
Greenhorn
Joined: Dec 27, 2001
Posts: 17
posted
0
Which of the following describe the sequence of method calls that result in a component being redrawn? a) invoke paint() directly b) invoke update which calls paint() c) invoke repaint() which invokes update(), which in turn invokes paint() d) invoke repaint() which invokes paint directly
I think the correct answer is repaint->update->paint . Deepti
Maulin Vasavada
Ranch Hand
Joined: Nov 04, 2001
Posts: 1865
posted
0
hi, i'm sure that for painting it 'd b , repaint->update->paint thats how double buffering is used to override default painting behavior to avoid flickers ... regards maulin.