Alien head

Java Thread Quiz

Description: Java Thread Quiz
Number of Questions: 8
Created by:
Tags: java

What is the name of the method used to start a thread execution?

  1. init();

  2. start();

  3. run();

  4. resume();

Answer: 2
Explanation:

The start() method causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread.

Which cannot directly cause a thread to stop executing?

  1. Calling the SetPriority() method on a Thread object.

  2. Calling the wait() method on an object.

  3. Calling notify() method on an object.

  4. Calling read() method on an InputStream object.

Answer: 3
Explanation:

notify() - wakes up a single thread that is waiting on this object's monitor.

Which of the following will directly stop the execution of a Thread?

  1. wait()

  2. notify()

  3. notifyall()

  4. exits synchronized code

Answer: 1

Which method must be defined by a class implementing the java.lang.Runnable interface?

  1. void run()

  2. public void run()

  3. public void start()

  4. void run(int priority)

Answer: 2

Which will contain the body of the thread?

  1. run();

  2. start();

  3. stop();

  4. main();

Answer: 1

Which method registers a thread in a thread scheduler?

  1. run();

  2. construct();

  3. start();

  4. register();

Answer: 3

Which of the following will not directly cause a thread to stop?

  1. notify()

  2. wait()

  3. InputStream access

  4. sleep()

Answer: 1

Which class or interface defines the wait(), notify(),and notifyAll() methods?

  1. Object

  2. Thread

  3. Runnable

  4. Class

Answer: 1
+ View questions