iGET

Java Programming - MCQ Practice Questions

Practice free Java Programming multiple-choice questions with detailed answers and explanations. Perfect for competitive exam preparation.

958 questions | 100% Free

Q.101Easy

Which of the following statements about Java threads is correct?

Q.102Easy

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

Q.103Easy

Which of the following will cause a deadlock situation?

Q.104Easy

Which collection class is thread-safe without explicit synchronization?

Q.105Easy

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

Q.106Easy

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

Q.107Easy

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

Q.108Easy

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

Q.109Easy

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

Q.110Easy

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

Q.111Easy

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

Q.112Easy

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

Which of the following is a checked exception in Java?

Q.114Easy

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

Q.115Easy

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

Q.116Easy

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

Q.117Easy

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

Q.118Easy

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

Q.119Easy

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

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