Java Multithreading: 17 MCQs with answers

All 17 multiple-choice questions from this kit, free and with no sign-up.

Warm-up · 6 questions

Q1. What is a thread in Java?

Beginner
A A lightweight sub-process that runs concurrently with other threads B A collection of objects C A separate program running independently D A class that contains only static methods
Show answer & explanation

A lightweight sub-process that runs concurrently with other threads

A thread is a lightweight sub-process, the smallest unit of execution that runs concurrently within a process.

Q2. Which of the following is the correct way to create a thread by implementing an interface?

Beginner
A Extend the Thread class B Implement the Thread interface C Implement the Runnable interface D Extend the Runnable class
Show answer & explanation

Implement the Runnable interface

Implementing the Runnable interface is one of the two ways to create a thread; the other is extending the Thread class.

Q3. Which method is called to start a thread's execution?

Beginner
A begin() B start() C execute() D run()
Show answer & explanation

start()

The start() method creates a new thread and calls the run() method inside that new thread.

Q4. What is the purpose of the run() method in a thread?

Beginner
A To pause the thread B To contain the code that executes when the thread is running C To start the thread D To stop the thread
Show answer & explanation

To contain the code that executes when the thread is running

The run() method holds the task that the thread performs; it is invoked by the start() method.

Q5. Which of the following is a benefit of multithreading?

Beginner
A It reduces memory usage by sharing all data B It always makes programs run faster on single-core CPUs C It allows concurrent execution of tasks, improving resource utilization D It eliminates the need for synchronization
Show answer & explanation

It allows concurrent execution of tasks, improving resource utilization

Multithreading allows multiple tasks to run concurrently, which improves CPU utilization and responsiveness.

Q6. The start() method can be called multiple times on the same thread object.

Beginner
A True B False
Show answer & explanation

False

Calling start() more than once on the same thread throws IllegalThreadStateException.

Building up · 8 questions

Q7. What is the default priority of a thread in Java?

Intermediate
A 0 B 5 C 1 D 10
Show answer & explanation

5

The default priority of a thread is NORM_PRIORITY, which is 5.

Q8. Which method causes the currently executing thread to pause temporarily and allow other threads to execute?

Intermediate
A wait() B yield() C sleep() D join()
Show answer & explanation

yield()

yield() causes the current thread to pause, giving other threads of the same priority a chance to run.

Q9. What is the purpose of the join() method?

Intermediate
A To interrupt a thread B To synchronize threads C To wait for a thread to finish before continuing D To combine two threads into one
Show answer & explanation

To wait for a thread to finish before continuing

join() makes the calling thread wait until the specified thread completes its execution.

Q10. Which keyword is used to make a method or block thread-safe?

Intermediate
A synchronized B volatile C final D transient
Show answer & explanation

synchronized

The synchronized keyword ensures that only one thread can access a method or block at a time, preventing race conditions.

Q11. What is a race condition?

Intermediate
A A condition where two threads run at different speeds B A thread that runs faster than others C A deadlock between threads D A situation where multiple threads access shared data concurrently, leading to inconsistent results
Show answer & explanation

A situation where multiple threads access shared data concurrently, leading to inconsistent results

A race condition occurs when multiple threads access shared data without proper synchronization, causing unpredictable outcomes.

Q12. Which method is used to interrupt a thread?

Intermediate
A cancel() B interrupt() C stop() D terminate()
Show answer & explanation

interrupt()

interrupt() sets the thread's interrupt status; the thread can then handle the interruption gracefully.

Q13. Which of the following is NOT a thread state in Java?

Intermediate
A WAITING B NEW C RUNNABLE D PAUSED
Show answer & explanation

PAUSED

PAUSED is not a valid thread state; the valid states are NEW, RUNNABLE, BLOCKED, WAITING, TIMED_WAITING, and TERMINATED.

Q14. Synchronization is used to prevent race conditions.

Intermediate
A True B False
Show answer & explanation

True

Synchronization ensures that only one thread accesses a critical section at a time, preventing race conditions.

Topper level · 3 questions

Q15. What is the state of a thread when it is waiting for a monitor lock?

Advanced
A BLOCKED B WAITING C RUNNABLE D TERMINATED
Show answer & explanation

BLOCKED

A thread enters the BLOCKED state when it tries to enter a synchronized block but the lock is held by another thread.

Q16. What is the purpose of the volatile keyword?

Advanced
A To make a variable thread-safe by ensuring visibility of changes across threads B To prevent a variable from being serialized C To increase the priority of a thread D To make a variable immutable
Show answer & explanation

To make a variable thread-safe by ensuring visibility of changes across threads

volatile ensures that changes to a variable are immediately visible to other threads, preventing caching issues.

Q17. What is a deadlock?

Advanced
A A thread that runs forever B A thread that is terminated abruptly C A thread that never starts D Two or more threads waiting indefinitely for each other's locks
Show answer & explanation

Two or more threads waiting indefinitely for each other's locks

Deadlock occurs when two or more threads are blocked forever, each waiting for a lock held by another.

Make your own

Your notes can be a kit like these

Every kit here was made from real study material. Point Veda at a chapter, a PDF, a photo or a link and get notes, flashcards, practice MCQs, games and a scored test — free, in 42 languages.

  • Chapter notes
  • Flashcards
  • Practice MCQs
  • Scored tests
  • Exam prep

Get Veda free See what students get

Free to start · No ads · Works in 42 languages