For the following code, all three threads will execute concurrently, taking time-sliced turns in the CPU(True/False). : Questions « Thread « SCJP






class MyThread extends Thread {
   MyThread() {
     setPriority(10);
   }

 public void run() {
   System.out.println("starting up.");
   while (true) { }
 }

 public static void main(String args[]) {
     MyThread p1 = new MyThread();
     MyThread p2 = new MyThread();
     MyThread p3 = new MyThread();
     p1.start();
     p2.start();
     p3.start();
   }
 }
 
A. True
B. False








7.10.Questions
7.10.1.What is the output(Runnable interface and thread)?
7.10.2.Answer: Runnable interface and thread
7.10.3.For the following code, all three threads will execute concurrently, taking time-sliced turns in the CPU(True/False).
7.10.4.Answer: Thread and CPU time
7.10.5.A thread can call the yield() method on the second thread to make a second thread ineligible for execution (True/False).
7.10.6.Answer: thread yield method
7.10.7.Which one of the following statements is correct?
7.10.8.Answer: thread and priority
7.10.9.Can you notify Thread1 in among 10 waiting threads so that it alone moves from the Waiting state to the Ready state?
7.10.10.Answer: thread and notify
7.10.11.What is the output
7.10.12.Answer: thread and run method
7.10.13.A Java monitor class must either extend Thread or implement Runnable(True/False).
7.10.14.Answer: monitor class
7.10.15.Every thread starts executing with a priority of 5(True/False).
7.10.16.Answer: thread and priority 5
7.10.17.Threads inherit their priority from their parent thread(True/False).
7.10.18.Answer: thread priority and inheritance
7.10.19.Threads are guaranteed to run with the priority set by setPriority() method(True/False).
7.10.20.Answer: set priority
7.10.21.Thread priority is an integer ranging from 1 to 100(True/False).
7.10.22.Answer: priority range
7.10.23.How to start the following thread
7.10.24.Answer: starting a thread
7.10.25.Which of the following methods are static methods of the Thread class?
7.10.26.Answer: static thread method
7.10.27.Which of the following statements is true after an application executes the following line:
7.10.28.Answer: thread priority
7.10.29.Which of the following statements about the wait method from Object class are true?
7.10.30.Answer: wait and object
7.10.31.Which of the following methods are instance not-deprecated methods of the Thread class?
7.10.32.Answer: deprecated thread methods