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
Which of the following statements about Java threads is correct?
What is the primary purpose of the volatile keyword in Java multithreading?
Which of the following will cause a deadlock situation?
Which collection class is thread-safe without explicit synchronization?
Which method is used to prevent race conditions by allowing only one thread to access a resource at a time?
Which of the following collections is thread-safe in Java?
What is the output of the following code? Thread t = new Thread(() -> System.out.println(Thread.currentThread().getName())); t.start();
Which method must be implemented to create a thread in Java?
What is the difference between start() and run() methods in threading?
Which of the following thread states is NOT a valid Java thread state?
Which of the following methods will cause a thread to release all locks it holds while waiting?
A developer needs to ensure that exactly 5 threads complete their tasks before proceeding to the next phase. Which synchronization utility is most appropriate?
Which of the following is a checked exception in Java?
Which exception is thrown when a method receives an illegal or inappropriate argument?
Can you have a try block without a catch block in Java?
Which of the following is NOT a subclass of Throwable in Java?
Which exception is thrown when trying to access a method of a null object?
Which exception is thrown when a string cannot be converted to a number?
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"); } } }
In Java exception handling, what is the order of execution in try-finally-catch block?