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.321Easy

Which of the following statements about the notify() method is correct?

Q.322Medium

What will be the output of the following code snippet? java class Test extends Thread { public void run() { System.out.print("T"); } } public class Main { public static void main(String[] args) { Test t = new Test(); t.run(); t.start(); } }

Q.323Easy

Which exception is thrown when a thread is interrupted while waiting?

Q.324Medium

Consider a scenario where Thread A acquires Lock1 and tries to acquire Lock2, while Thread B acquires Lock2 and tries to acquire Lock1. What situation arises?

Q.325Easy

What is the return type of the join() method in Java threading?

Q.326Medium

Which of the following is a thread-safe collection in Java that can be used without explicit synchronization?

Q.327Medium

Which method is used to check the current state of a thread in Java?

Q.328Medium

In the context of synchronized methods, what is acquired and released automatically?

Q.329Medium

What is the main advantage of using ExecutorService over directly creating threads?

Q.330Hard

Consider the following code. What will be the likely behavior? java synchronized void method1() { method2(); } synchronized void method2() { }

Q.331Hard

Which class is used to synchronize the execution of multiple threads at a specific point?

Q.332Hard

What is the difference between CountDownLatch and CyclicBarrier?

Q.333Medium

In a multithreaded application, what does the term 'context switching' refer to?

Q.334Hard

What will happen if a thread tries to acquire a lock it already holds while inside a synchronized method?

Q.335Easy

Which of the following best describes the purpose of the Runnable interface in Java?

Q.336Hard

In a high-concurrency scenario with 2024-25 exam patterns, which Java construct provides the best lock-free approach for thread safety?

Q.337Easy

Which of the following statements about Java threads is correct?

Q.338Easy

What is the primary purpose of the volatile keyword in Java multithreading?

Q.339Easy

Which of the following will cause a deadlock situation?

Q.340Medium

In Java 21 (latest), which is a modern approach to create thread-safe operations?