Java Reference
In-Depth Information
Review Questions
1.
Name the one method in the java.lang.Runnable interface.
2.
True or False: A process that has no threads running in it will terminate.
3.
True or False: If the only threads left in a process are daemon threads, the process will
terminate.
4.
Which one of the following statements is not true?
a. The maximum priority of a Java thread is the value Thread.MAX_PRIORITY.
b. If a thread of priority 5 is running and a priority 8 thread becomes runnable, it
will preempt the priority 5 thread.
c. Because Java programs run on a JVM, the behavior of the underlying platform
does not affect your Java threads.
d. By default, a new thread inherits the priority of the thread that started it.
5.
True or False: A born thread does not run until the start() method is invoked.
6.
True or False: The number of threads currently running depends on how many
threads are waiting in the runnable priority queues.
7.
List three different ways to create a thread in Java.
8.
Suppose that threads A and B are the only two threads in a process, and A has priority
5 and B priority 10. Which of the following statements is (are) guaranteed to be true?
Select all that apply.
a. Thread B will run to completion before A gets a chance to execute.
b. If thread B invokes yield(), thread A will be scheduled to run.
c. If thread B invokes sleep(), thread A will be scheduled to run.
d. If the underlying platform uses time slicing, threads A and B will receive equal
time on the CPU.
e. Deadlock cannot occur because B has a higher priority.
f. If B calls join() on A, B will block until A runs to completion.
9.
Suppose that a task is scheduled using the following statement:
someTimer.schedule(someTask, 0, 10000);
Which of the following statements is (are) true? Select all that apply.
a. The task will be scheduled immediately.
b. The task will be scheduled in exactly 10 seconds.
c. The task will be scheduled 10 seconds after its first completion.
d. The task will execute once, in 10 seconds.
e. The task will execute exactly 10,000 times.
Search WWH ::




Custom Search