iGET

Java Programming - MCQ Practice Questions

Practice free Java Programming multiple-choice questions with detailed answers and explanations. Perfect for competitive exam preparation.

951 questions | 100% Free

Q.61Medium

What is CyclicBarrier used for in multithreading?

Q.62Medium

Which of the following is true about CountDownLatch?

Q.63Medium

What is the purpose of the wait() method in Java?

Q.64Medium

In a synchronized block, if notifyAll() is called, what happens?

Q.65Medium

What is the primary difference between Semaphore and Mutex?

Q.66Medium

What happens when Thread.interrupt() is called on a thread?

Q.67Hard

Consider a scenario: Thread A is waiting in wait() inside a synchronized block. Thread B calls notify(). What is the state of Thread A?

Q.68Medium

In a deadlock scenario, which of the following is always true?

Q.69Easy

Which of the following collections is thread-safe in Java?

Q.70Medium

What is the key difference between Callable and Runnable?

Q.71Hard

In a high-concurrency scenario using Java 21, which approach is recommended for I/O-bound operations?

Q.72Hard

What is the purpose of the strictfp modifier in the context of multithreading?

Q.73Hard

In a producer-consumer problem, what is the ideal synchronization mechanism?

Q.74Easy

What is the output of the following code? Thread t = new Thread(() -> System.out.println(Thread.currentThread().getName())); t.start();

Q.75Easy

Which method must be implemented to create a thread in Java?

Q.76Easy

What is the difference between start() and run() methods in threading?

Q.77Easy

Which of the following thread states is NOT a valid Java thread state?

Q.78Medium

What will happen if you try to call start() on a thread that has already completed execution?

Q.79Medium

Consider the code: synchronized void method1() { wait(); } If wait() is called without a lock, what happens?

Q.80Medium

What is the purpose of the yield() method in Java threading?