Sail E0 Webinar

MCQs

Total Questions : 86 | Page 8 of 9 pages
Question 71.

Which of these statement is incorrect?


  1.    A thread can be formed by implementing Runnable interface only.
  2.    A thread can be formed by a class that extends Thread class.
  3.    start() method is used to begin execution of the thread.
  4.    run() method is used to begin execution of a thread before start() method in special cases.
 Discuss Question
Answer: Option D. -> run() method is used to begin execution of a thread before start() method in special cases.

run() method is used to define the code that constitutes the new thread, it contains the code 

to be executed. start() method is used to begin execution of the thread that is execution of 

run(). run() itself is never used for starting execution of the thread.


Question 72.

Which of these method waits for the thread to treminate?


  1.    sleep()
  2.    isAlive()
  3.    join()
  4.    stop()
 Discuss Question
Answer: Option C. -> join()

None.


Question 73.

Which of these method waits for the thread to treminate?


  1.    sleep()
  2.    isAlive()
  3.    join()
  4.    stop()
 Discuss Question
Answer: Option C. -> join()

None.


Question 74.

Which three are methods of the Object class?

    1. notify();

    2. notifyAll();

    3. isInterrupted();

    4. synchronized();

    5. interrupt();

    6. wait(long msecs);

    7. sleep(long msecs);

    8. yield();


  1.    1, 2, 4
  2.    2, 4, 5
  3.    1, 2, 6
  4.    2, 3, 4
 Discuss Question
Answer: Option C. -> 1, 2, 6

(1), (2), and (6) are correct. They are all related to the list of threads waiting on the 

specified object.

(3), (5), (7), and (8) are incorrect answers. The methods isInterrupted() and interrupt() 

are instance methods of Thread.

The methods sleep() and yield() are static methods of Thread.

D is incorrect because synchronized is a keyword and the synchronized() construct is part of 

the Java language.


Question 75.

What is the default value of priority variable MIN_PRIORITY AND MAX_PRIORITY?


  1.    0 & 256
  2.    0 & 1
  3.    1 & 10
  4.    1 & 256
 Discuss Question
Answer: Option C. -> 1 & 10

None.


Question 76.

Which of these method is used to begin the execution of a thread?


  1.    run()
  2.    start()
  3.    runThread()
  4.    startThread()
 Discuss Question
Answer: Option B. -> start()

None.


Question 77.

Which of these method wakes up the first thread that called wait()?


  1.    wake()
  2.    notify()
  3.    start()
  4.    notifyAll()
 Discuss Question
Answer: Option B. -> notify()

 None.


Question 78.

Which of these method is used to tell the calling thread to give up monitor and 

go to sleep until some other thread enters the same monitor?


  1.    wait()
  2.    notify()
  3.    notifyAll()
  4.    sleep()
 Discuss Question
Answer: Option A. -> wait()

wait() method is used to tell the calling thread to give up monitor and go to sleep until some 

Question 79.

Which of these method is used to find out that a thread is still running or not?


  1.    run()
  2.    Alive()
  3.    isAlive()
  4.    checkRun()
 Discuss Question
Answer: Option C. -> isAlive()

The isAlive( ) method returns true if the thread upon which it is called is still running. It 

returns false otherwise.


Question 80.

Which of these method is used to avoid polling in Java?


  1.    wait()
  2.    notify())
  3.    notifyAll()
  4.    All of the mentioned
 Discuss Question
Answer: Option D. -> All of the mentioned

Polling is a usually implemented by looping in CPU is wastes CPU's time, one thread 

being executed depends on other thread output and the other hread depends on the 

response on the data given to the first thread. In such situation CPU's time is wasted, 

in Java this is avoided by using methods wait(), notify() and notifyAll().



Latest Videos

Latest Test Papers