Sail E0 Webinar

MCQs

Total Questions : 22 | Page 2 of 3 pages
Question 11. Which of these class is used to make a thread?
  1.    String
  2.    System
  3.    Thread
  4.    Runnable
 Discuss Question
Answer: Option C. -> Thread


Thread class is used to make threads in java, Thread encapsulates a thread of execution. To create a new thread the program will either extend Thread or implement the Runnable interface.


Question 12. 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 13. Which of these interface is implemented by Thread class?
  1.    Runnable
  2.    Connections
  3.    Set
  4.    MapConnections
 Discuss Question
Answer: Option A. -> Runnable


Runnable


Question 14. Which of these method of Thread class is used to Suspend a thread for a period of time?
  1.    sleep()
  2.    terminate()
  3.    suspend()
  4.    stop()
 Discuss Question
Answer: Option A. -> sleep()


sleep()


Question 15. Which of these method of Thread class is used to find out the priority given to a thread?
  1.    get()
  2.    ThreadPriority()
  3.    getPriority()
  4.    getThreadPriority()
 Discuss Question
Answer: Option C. -> getPriority()


getPriority()


Question 16. What will happen if two thread of same priority are called to be processed simultaneously?
  1.    Any one will be executed first lexographically
  2.    Both of them will be executed simultaneously
  3.    None of them will be executed
  4.    It is dependent on the operating system.
 Discuss Question
Answer: Option D. -> It is dependent on the operating system.


In cases where two or more thread with same priority are competing for CPU cycles, different operating system handle this situation differently. Some execute them in time sliced manner some depending on the thread they call.


Question 17. Which of these statements is incorrect?
  1.    By multithreading CPU's idle time is minimized, and we can take maximum use of it.
  2.    By multitasking CPU's idle time is minimized, and we can take maximum use of it.
  3.    Two thread in Java can have same priority
  4.    A thread can exist only in two states, running and blocked.
 Discuss Question
Answer: Option D. -> A thread can exist only in two states, running and blocked.


Thread exist in several states, a thread can be running, suspended, blocked, terminated & ready to run.


Question 18. What is multithreaded programming?
  1.    It's a process in which two different processes run simultaneously.
  2.    It's a process in which two or more parts of same process run simultaneously.
  3.    Its a process in which many different process are able to access same information.
  4.    Its a process in which a single process can access information from many sources.
 Discuss Question
Answer: Option B. -> It's a process in which two or more parts of same process run simultaneously.


multithreaded programming a process in which two or more parts of same process run simultaneously.


Question 19. Which function of pre defined class Thread is used to check weather current thread being checked is still running?
  1.    isAlive()
  2.    Join()
  3.    isRunning()
  4.    Alive()
 Discuss Question
Answer: Option A. -> isAlive()


isAlive() function is defined in class Thread, it is used for implementing multithreading and to check whether the thread called
upon is still running or not.


Question 20. Which of these packages contain all the Java's built in exceptions?
  1.    java.io
  2.    java.util
  3.    java.lang
  4.    java.net
 Discuss Question
Answer: Option C. -> java.lang


java.lang


Latest Videos

Latest Test Papers