• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

some questions

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
qunlbao,
Please read the Javaranch Naming Policy and register again.
Thank you for your cooperation.
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
2、private
Private method in super class can not be overriden
by subclass,and private method do exist in subclass
Am I right?
 
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your help
Now I have changed my name from "qunlbao"
to "qunlbao leon"
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic