aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes mock exam q Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "mock exam q" Watch "mock exam q" New topic
Author

mock exam q

anrup kris
Greenhorn

Joined: Oct 22, 2000
Posts: 17
I saw two questions in John Hunt's mock exam which seemed ambiguous to me
Q. 34
Which methods may cause a thread to stop executing?
a) sleep();
b) stop();
C) yield();
d) wait();
e) notify();
f) notifyAll()
g) synchronized()
Select all correct answers.

Q. 30
What class must an inner class extend:
a) The top level class
b) The Object class
c) Any class or interface
d) It must extend an interface
Select the most appropriate answer
The correct answers are :
34) a,b,c,d
30) c
My question is:
1) shouldn't the question 34 have been "Which methods may cause a thread to stop running?" instead of "Which methods may cause a thread to stop executing?"
I chose (b)
2)I thought only anonymous inner classes need to implement an interface or extend a class.The way the q is phrased,it seems like all inner classes need to implement an interface or extend a class.Is this correct?
I chose (b) because all classes indirectly extend Object class
thankx in advance for your response
kris
chetan nain
Ranch Hand

Joined: Jun 21, 2000
Posts: 159
1.
lets regard your rephrasing of the question to "running"
option1: sleep() - static method of Thread class. if a thread is put to sleep, it will go to a blocking state for the time specified. it is not necessary for the thread to own the monitor of the object at the time of invocation of sleep() (although, if the thread DOES own monitor, it will NOT release the same).
on sleeping for specified time, it will go into READY state and then the thread is at the mercy fo the scheduler.
THUS< IT HAS STOPPED EXECUTING TEMPORARILY TILL THE SCHEDULER DECIDES TO RERUN IT.
option 2: true
option 3: yield() is static method of thread class. on execution of the same, the thread will immediately from running state to waiting to run state. thus., it has stopped executing temporairly.(note that yield() is used to allow threads of same priority to run)
option 4: wait(). on execution of this method, the thread will release the monitor it holds, and will go to the waiting state. if another thread calls interrupt() on this thread, an Interrupted exception will be thrown, and the thread will go to the ready state. if the scheduler decided to run this thread , the code in the try{}catch{InterruptedException} block will be executed
thus, options 1,2,3,4,are true
hth,
chetan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: mock exam q