iGET

Java Programming - MCQ Practice Questions

Java interviews and campus tests lean heavily on object oriented behaviour rather than API recall. This set covers inheritance and polymorphism, interfaces and abstract classes, the collections framework, exception handling, multithreading, string handling, and JVM basics such as garbage collection. Output based questions are included because they expose the gaps that theory questions hide.

951 questions | 100% Free

Q.361Medium

Which of the following is true about CountDownLatch?

Q.362Medium

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

Q.363Medium

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

Q.364Medium

What is the primary difference between Semaphore and Mutex?

Q.365Medium

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

Q.366Hard

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

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

Q.368Easy

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

Q.369Medium

What is the key difference between Callable and Runnable?

Q.370Hard

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

Q.371Hard

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

Q.372Hard

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

Q.373Easy

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

Q.374Easy

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

Q.375Easy

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

Q.376Easy

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

Q.377Medium

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

Q.378Medium

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

Q.379Medium

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

Q.380Medium

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