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

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

Q.102Easy

Which of the following will cause a deadlock situation?

Q.103Easy

Which collection class is thread-safe without explicit synchronization?

Q.104Easy

Which method is used to prevent race conditions by allowing only one thread to access a resource at a time?

Q.105Easy

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

Q.106Easy

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

Q.107Easy

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

Q.108Easy

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

Q.109Easy

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

Q.110Easy

Which of the following methods will cause a thread to release all locks it holds while waiting?

Q.111Easy

A developer needs to ensure that exactly 5 threads complete their tasks before proceeding to the next phase. Which synchronization utility is most appropriate?

Q.112Easy

Which of the following is a checked exception in Java?

Q.113Easy

Which exception is thrown when a method receives an illegal or inappropriate argument?

Q.114Easy

Can you have a try block without a catch block in Java?

Q.115Easy

Which of the following is NOT a subclass of Throwable in Java?

Q.116Easy

Which exception is thrown when trying to access a method of a null object?

Q.117Easy

Which exception is thrown when a string cannot be converted to a number?

Q.118Easy

What is the output of this code? public class Test { public static void main(String[] args) { try { int[] arr = {1, 2}; System.out.println(arr[5]); } catch (Exception e) { System.out.println("Caught"); } } }

Q.119Easy

In Java exception handling, what is the order of execution in try-finally-catch block?

Q.120Easy

Which exception is thrown when a numeric string cannot be converted to a number?