• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

William Brogden MOCK

 
Sarma Lolla
Ranch Hand
Posts: 203
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question 55
Which of the following are public variables or methods that belong to an instance of Thread?
Do not select static variables, static methods, or deprecated methods.
Choice Option Text
a - wait() method
b - sleep() method
c - start() method
d - MAX_PRIORITY - an int variable
e - daemon - a boolean variable
Correct answers are a) and c). But given that the correct answers can be one or more as the general statement how can any one guess a) as answer?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13044
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll admit that one is a little tricky. Here is the complete script:

TXT:1: Which of the following are public variables or methods that belong to an instance of Thread?
TXT:2: Do not select static variables, static methods, or deprecated methods.
OPT:a: wait() method
OPT:b: sleep() method
OPT:c: start() method
OPT : MAX_PRIORITY - an int variable
OPT:e: daemon - a boolean variable
ANS:a: Yes, since wait is a method in Object and Thread is an object.
ERR:b: No, sleep is a static method.
ANS:c: Yes, start is an instance method of Thread.
ERR : No, MAX_PRIORITY is a static final variable of Thread.
ERR:e: No, the daemon boolean variable is a private instance variable.

What I am trying to get at there is to remind you that objects have methods inherited all the way back to Object.
Even though I can't think of a reason to design a program such that wait method would be called, you should still recognize that it has one by virtue of inheritance.
Bill
[ March 03, 2003: Message edited by: William Brogden ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic