iGET

Java Programming - MCQ Practice Questions

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

958 questions | 100% Free

Q.61Medium

What does the volatile keyword guarantee in Java multithreading?

Q.62Medium

What is the output of the following code? volatile int counter = 0; counter++; // in multiple threads Which issue may occur?

Q.63Medium

What is CyclicBarrier used for in multithreading?

Q.64Medium

Which of the following is true about CountDownLatch?

Q.65Medium

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

Q.66Medium

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

Q.67Medium

What is the primary difference between Semaphore and Mutex?

Q.68Medium

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

Q.69Hard

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.70Medium

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

Q.71Easy

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

Q.72Medium

What is the key difference between Callable and Runnable?

Q.73Hard

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

Q.74Hard

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

Q.75Hard

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

Q.76Easy

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

Q.77Easy

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

Q.78Easy

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

Q.79Easy

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

Q.80Medium

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

Java Programming MCQs – Free Practice Test | iGET | iGET