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

What is the difference between Thread.sleep() and Thread.yield()?

Q.302Easy

Which method is used to stop a thread in Java?

Q.303Medium

What is the purpose of the synchronized keyword in Java multithreading?

Q.304Medium

Which of the following is NOT a thread state in Java?

Q.305Medium

What will be the output of calling start() multiple times on the same thread object?

Q.306Easy

Which method is called to make a thread wait until another thread completes?

Q.307Medium

What is a race condition in multithreading?

Q.308Medium

Consider a synchronized method. Can multiple threads call it simultaneously on the same object?

Q.309Medium

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

Q.310Medium

Which class provides thread-safe operations on shared variables in Java?

Q.311Hard

What happens when wait() is called from a thread that doesn't hold the lock?

Q.312Medium

What is a daemon thread in Java?

Q.313Easy

Which of the following is a valid way to create a thread in Java?

Q.314Medium

What is a deadlock in multithreading?

Q.315Hard

How does the volatile keyword help in multithreading?

Q.316Hard

What will happen if you call sleep() inside a synchronized block?

Q.317Hard

Which interface allows multiple threads to access a resource with a permit system?

Q.318Medium

What is thread pooling and which class is commonly used for it?

Q.319Hard

Consider code where Thread A holds Lock1 and waits for Lock2, while Thread B holds Lock2 and waits for Lock1. What is this scenario called?

Q.320Easy

In Java multithreading, which method is used to pause the execution of a thread for a specified number of milliseconds without releasing locks?