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

Which interface would you use to submit multiple tasks and wait for all of them to complete?

Q.22Medium

What is the difference between notify() and notifyAll() in Java?

Q.23Medium

Which of the following best describes CyclicBarrier?

Q.24Medium

What happens when a thread acquires a lock on an object and then calls wait()?

Q.25Medium

In a scenario where Thread A holds Lock1 and waits for Lock2, while Thread B holds Lock2 and waits for Lock1, what is this called?

Q.26Medium

What is the output of this code? ExecutorService executor = Executors.newSingleThreadExecutor(); executor.submit(() -> System.out.println("Task 1")); executor.submit(() -> System.out.println("Task 2")); executor.shutdown();

Q.27Medium

Which method is used to forcefully stop a thread in modern Java?

Q.28Medium

What happens if an exception is thrown inside a synchronized block?

Q.29Medium

In Java 21 Virtual Threads, what is the key advantage over platform threads?

Q.30Medium

What does the volatile keyword guarantee in Java multithreading?

Q.31Medium

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

Q.32Medium

What is CyclicBarrier used for in multithreading?

Q.33Medium

Which of the following is true about CountDownLatch?

Q.34Medium

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

Q.35Medium

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

Q.36Medium

What is the primary difference between Semaphore and Mutex?

Q.37Medium

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

Q.38Medium

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

Q.39Medium

What is the key difference between Callable and Runnable?

Q.40Medium

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