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

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

Q.42Medium

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

Q.43Medium

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

Q.44Medium

Which Java class provides thread-safe operations using Compare-And-Swap (CAS)?

Q.45Medium

What does the volatile keyword guarantee in multithreading?

Q.46Medium

In Java 21, which new feature was introduced for concurrent programming?

Q.47Medium

What is the output of this code snippet? ExecutorService es = Executors.newFixedThreadPool(2); es.execute(() -> System.out.println("Task 1")); es.shutdown();

Q.48Medium

What exception does CyclicBarrier throw when a thread is interrupted while waiting?

Q.49Medium

In a producer-consumer scenario using BlockingQueue, what happens when a consumer thread calls take() on an empty queue?

Q.50Medium

A multi-threaded application experiences poor performance despite having adequate CPU cores. Code inspection reveals frequent calls to synchronized blocks on shared objects. Which modern Java feature (2024-25) could optimize this without major refactoring?