InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Which of these method wakes up the first thread that called wait()?(a) wake()(b) notify()(c) start()(d) notifyAll()The question was asked in an online interview.My question comes from Creating Threads in section Multithreading of Java |
| Answer» | |
| 2. |
Which of these method wakes up all the threads?(a) wakeAll()(b) notify()(c) start()(d) notifyAll()This question was addressed to me at a job interview.My doubt is from Creating Threads topic in division Multithreading of Java |
|
Answer» Correct answer is (d) notifyAll() |
|
| 3. |
Which of these method is used to tell the calling thread to give up a monitor and go to sleep until some other thread enters the same monitor?(a) wait()(b) notify()(c) notifyAll()(d) sleep()I had been asked this question in quiz.My query is from Creating Threads topic in division Multithreading of Java |
|
Answer» Correct option is (a) WAIT() |
|
| 4. |
Which of this method is used to avoid polling in Java?(a) wait()(b) notify()(c) notifyAll()(d) all of the mentionedI got this question in my homework.The query is from Creating Threads in portion Multithreading of Java |
|
Answer» Correct choice is (d) all of the mentioned |
|
| 5. |
Which of these keywords are used to implement synchronization?(a) synchronize(b) syn(c) synch(d) synchronizedThis question was addressed to me in a job interview.I need to ask this question from Creating Threads topic in portion Multithreading of Java |
|
Answer» RIGHT ANSWER is (d) synchronized Best EXPLANATION: NONE. |
|
| 6. |
Which of the following will ensure the thread will be in running state?(a) yield()(b) notify()(c) wait()(d) Thread.killThread()I have been asked this question in homework.I need to ask this question from Multithreading topic in section Multithreading of Java |
|
Answer» RIGHT OPTION is (c) wait() The explanation is: wait() always causes the current thread to GO into the object’s wait pool. Hence, USING this in a thread will keep it in RUNNING state. |
|
| 7. |
Which of the following stops execution of a thread?(a) Calling SetPriority() method on a Thread object(b) Calling notify() method on an object(c) Calling wait() method on an object(d) Calling read() method on an InputStream objectI have been asked this question during a job interview.The query is from Multithreading topic in chapter Multithreading of Java |
|
Answer» Right choice is (b) Calling NOTIFY() method on an object |
|
| 8. |
Which of the following is a correct constructor for thread?(a) Thread(Runnable a, String str)(b) Thread(int priority)(c) Thread(Runnable a, int priority)(d) Thread(Runnable a, ThreadGroup t)This question was posed to me in an international level competition.My enquiry is from Multithreading topic in division Multithreading of Java |
|
Answer» Right answer is (a) Thread(Runnable a, STRING str) |
|
| 9. |
What is true about threading?(a) run() method calls start() method and runs the code(b) run() method creates new thread(c) run() method can be called directly without start() method being called(d) start() method creates new thread and calls code written in run() methodI got this question in semester exam.The query is from Multithreading in division Multithreading of Java |
|
Answer» Correct choice is (d) START() method CREATES new thread and calls code WRITTEN in run() method |
|
| 10. |
What should not be done to avoid deadlock?(a) Avoid using multiple threads(b) Avoid hold several locks at once(c) Execute foreign code while holding a lock(d) Use interruptible locksI have been asked this question in examination.Question is from Multithreading topic in chapter Multithreading of Java |
|
Answer» Correct CHOICE is (C) Execute foreign CODE while holding a lock |
|
| 11. |
Deadlock is a situation when thread is waiting for other thread to release acquired object.(a) True(b) FalseThis question was posed to me during an online interview.I'd like to ask this question from Multithreading in chapter Multithreading of Java |
|
Answer» The correct option is (a) True |
|
| 12. |
What is true about time slicing?(a) Time slicing is OS service that allocates CPU time to available runnable thread(b) Time slicing is the process to divide the available CPU time to available runnable thread(c) Time slicing depends on its implementation in OS(d) Time slicing allocates more resources to threadI had been asked this question in homework.This question is from Multithreading topic in section Multithreading of Java |
|
Answer» The correct answer is (B) TIME slicing is the process to divide the available CPU time to available RUNNABLE thread |
|
| 13. |
What does not prevent JVM from terminating?(a) Process(b) Daemon Thread(c) User Thread(d) JVM ThreadI have been asked this question in an international level competition.My question comes from Multithreading topic in chapter Multithreading of Java |
|
Answer» RIGHT option is (B) Daemon Thread For explanation: Daemon thread RUNS in the background and does not prevent JVM from terminating. Child of daemon thread is also daemon thread. |
|
| 14. |
What decides thread priority?(a) Process(b) Process scheduler(c) Thread(d) Thread schedulerThe question was asked in a job interview.My question is based upon Multithreading in portion Multithreading of Java |
|
Answer» The correct option is (d) Thread SCHEDULER |
|
| 15. |
What requires less resources?(a) Thread(b) Process(c) Thread and Process(d) Neither Thread nor ProcessI got this question in an interview.The doubt is from Multithreading topic in portion Multithreading of Java |
|
Answer» Right answer is (a) Thread |
|
| 16. |
What will happen if two thread of the same priority are called to be processed simultaneously?(a) Anyone will be executed first lexographically(b) Both of them will be executed simultaneously(c) None of them will be executed(d) It is dependent on the operating systemI have been asked this question in exam.This interesting question is from Multithreading Basics in section Multithreading of Java |
|
Answer» The correct answer is (d) It is dependent on the operating system |
|
| 17. |
Thread priority in Java is?(a) Integer(b) Float(c) double(d) longThe question was asked in an online interview.My enquiry is from Multithreading Basics in chapter Multithreading of Java |
|
Answer» RIGHT option is (a) Integer Explanation: Java assigns to each thread a priority that determines HOE that thread should be TREATED with RESPECT to others. Thread priority is integers that specify relative priority of one thread to ANOTHER. |
|
| 18. |
Which of these are types of multitasking?(a) Process based(b) Thread based(c) Process and Thread based(d) None of the mentionedThe question was posed to me in final exam.This key question is from Multithreading Basics in chapter Multithreading of Java |
|
Answer» CORRECT option is (c) Process and THREAD BASED Explanation: There are two types of MULTITASKING: Process based multitasking and Thread based multitasking. |
|
| 19. |
What is multithreaded programming?(a) It’s a process in which two different processes run simultaneously(b) It’s a process in which two or more parts of same process run simultaneously(c) It’s a process in which many different process are able to access same information(d) It’s a process in which a single process can access information from many sourcesI got this question during an online interview.I want to ask this question from Multithreading Basics topic in section Multithreading of Java |
|
Answer» Right choice is (b) It’s a process in which TWO or more parts of same process run simultaneously |
|
| 20. |
Which of these method of Thread class is used to Suspend a thread for a period of time?(a) sleep()(b) terminate()(c) suspend()(d) stop()This question was posed to me in an interview.My question is from Thread class in portion Multithreading of Java |
|
Answer» The CORRECT CHOICE is (a) sleep() |
|
| 21. |
Which of these method of Thread class is used to find out the priority given to a thread?(a) get()(b) ThreadPriority()(c) getPriority()(d) getThreadPriority()I have been asked this question in an interview for internship.The question is from Thread class topic in division Multithreading of Java |
|
Answer» CORRECT OPTION is (C) getPriority() The EXPLANATION is: NONE. |
|
| 22. |
Which of these statement is incorrect?(a) A thread can be formed by implementing Runnable interface only(b) A thread can be formed by a class that extends Thread class(c) start() method is used to begin execution of the thread(d) run() method is used to begin execution of a thread before start() method in special casesThis question was posed to me in an online quiz.The doubt is from Implementing Runnable interface for Threads in section Multithreading of Java |
|
Answer» CORRECT choice is (d) run() method is used to begin execution of a thread before start() method in special cases To explain: 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. |
|
| 23. |
Which of these method is used to begin the execution of a thread?(a) run()(b) start()(c) runThread()(d) startThread()I have been asked this question during an internship interview.My enquiry is from Implementing Runnable interface for Threads in chapter Multithreading of Java |
|
Answer» Correct ANSWER is (B) START() |
|
| 24. |
Which of these method is used to implement Runnable interface?(a) stop()(b) run()(c) runThread()(d) stopThread()The question was posed to me during an interview for a job.This intriguing question comes from Implementing Runnable interface for Threads in division Multithreading of Java |
|
Answer» Correct option is (b) run() |
|
| 25. |
What is synchronization in reference to a thread?(a) It’s a process of handling situations when two or more threads need access to a shared resource(b) It’s a process by which many thread are able to access same shared resource simultaneously(c) It’s a process by which a method is able to access many different threads simultaneously(d) It’s a method that allow too many threads to access any information requireThe question was asked in class test.My doubt is from isAlive(), Join() & Thread Synchronization topic in section Multithreading of Java |
|
Answer» Right choice is (a) It’s a PROCESS of handling situations when two or more threads NEED access to a shared resource |
|
| 26. |
Which of this method is used to find out that a thread is still running or not?(a) run()(b) Alive()(c) isAlive()(d) checkRun()The question was asked in a national level competition.I'd like to ask this question from isAlive(), Join() & Thread Synchronization topic in chapter Multithreading of Java |
|
Answer» Correct answer is (c) isAlive() |
|
| 27. |
Which of these method is used to explicitly set the priority of a thread?(a) set()(b) make()(c) setPriority()(d) makePriority()The question was posed to me in an international level competition.The origin of the question is isAlive(), Join() & Thread Synchronization in division Multithreading of Java |
|
Answer» RIGHT OPTION is (c) setPriority() Easiest explanation: The default value of PRIORITY given to a thread is 5 but we can explicitly CHANGE that value between the permitted values 1 & 10, this is DONE by using the method setPriority(). |
|
| 28. |
Which of these method waits for the thread to terminate?(a) sleep()(b) isAlive()(c) join()(d) stop()This question was addressed to me in my homework.My enquiry is from isAlive(), Join() & Thread Synchronization topic in division Multithreading of Java |
|
Answer» Correct ANSWER is (C) join() |
|
| 29. |
What is the default value of priority variable MIN_PRIORITY AND MAX_PRIORITY?(a) 0 & 256(b) 0 & 1(c) 1 & 10(d) 1 & 256I had been asked this question during an internship interview.This question is from isAlive(), Join() & Thread Synchronization topic in section Multithreading of Java |
|
Answer» CORRECT OPTION is (C) 1 & 10 Explanation: NONE. |
|
| 30. |
Which of this method can be used to make the main thread to be executed last among all the threads?(a) stop()(b) sleep()(c) join()(d) call()This question was posed to me in exam.My query is from isAlive(), Join() & Thread Synchronization topic in portion Multithreading of Java |
|
Answer» Correct choice is (b) sleep() |
|