1-
|
What is the name of the method used to start a thread execution?
|
|
A -
|
init();
|
|
B -
|
start();
|
|
C -
|
run();
|
|
D -
|
resume();
|
2-
|
Which two are valid constructors for Thread?
- Thread(Runnable r, String name)
- Thread()
- Thread(int priority)
- Thread(Runnable r, ThreadGroup g)
- Thread(Runnable r, int priority)
|
|
A -
|
1 and 3
|
|
B -
|
2 and 4
|
|
C -
|
1 and 2
|
|
D -
|
2 and 5
|
3-
|
Which three are methods of the Object class?
- notify();
- notifyAll();
- isInterrupted();
- synchronized();
- interrupt();
- wait(long msecs);
- sleep(long msecs);
- yield();
|
|
A -
|
1, 2, 4
|
|
B -
|
2, 4, 5
|
|
C -
|
1, 2, 6
|
|
D -
|
2, 3, 4
|
4-
|
class X implements Runnable
{
public static void main(String args[])
{
/* Missing code? */
}
public void run() {}
}
Which of the following line of code is suitable to start a thread ?
|
|
A -
|
Thread t = new Thread(X);
|
|
B -
|
Thread t = new Thread(X); t.start();
|
|
C -
|
X run = new X(); Thread t = new Thread(run); t.start();
|
|
D -
|
Thread t = new Thread(); x.run();
|
5-
|
Which cannot directly cause a thread to stop executing?
|
|
A -
|
Calling read() method on an InputStream object.
|
|
B -
|
Calling notify() method on an object.
|
|
C -
|
Calling the wait() method on an object.
|
|
D -
|
Calling the SetPriority() method on a Thread object.
|
6-
|
Which two of the following methods are defined in class Thread?
- start()
- wait()
- notify()
- run()
- terminate()
|
|
A -
|
1 and 4
|
|
B -
|
2 and 3
|
|
C -
|
3 and 4
|
|
D -
|
2 and 4
|
7-
|
Which three guarantee that a thread will leave the running state?
- yield()
- wait()
- notify()
- notifyAll()
- sleep(1000)
- aLiveThread.join()
- Thread.killThread()
|
|
A -
|
1, 2 and 4
|
|
B -
|
2, 5 and 6
|
|
C -
|
3, 4 and 7
|
|
D -
|
4, 5 and 7
|
8-
|
Which of the following will directly stop the execution of a Thread?
|
|
A -
|
wait()
|
|
B -
|
notify()
|
|
C -
|
notifyall()
|
|
D -
|
exits synchronized code
|
9-
|
Which method must be defined by a class implementing the java.lang.Runnable interface?
|
|
A -
|
void run()
|
|
B -
|
public void run()
|
|
C -
|
public void start()
|
|
D -
|
void run(int priority)
|
10-
|
Which will contain the body of the thread?
|
|
A -
|
run();
|
|
B -
|
start();
|
|
C -
|
stop();
|
|
D -
|
main();
|