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

What does the volatile keyword guarantee in Java multithreading?

Q.362Medium

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

Q.363Medium

What is CyclicBarrier used for in multithreading?

Q.364Medium

Which of the following is true about CountDownLatch?

Q.365Medium

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

Q.366Medium

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

Q.367Medium

What is the primary difference between Semaphore and Mutex?

Q.368Medium

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

Q.369Hard

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

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

Q.371Easy

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

Q.372Medium

What is the key difference between Callable and Runnable?

Q.373Hard

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

Q.374Hard

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

Q.375Hard

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

Q.376Easy

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

Q.377Easy

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

Q.378Easy

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

Q.379Easy

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

Q.380Medium

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