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

Which exception is thrown when a method argument is null but shouldn't be?

Q.442Medium

What happens if you use 'return' statement inside a finally block?

Q.443Hard

Which of the following is NOT a characteristic of Exception class in Java?

Q.444Medium

What will be printed? public class Test { public static void main(String[] args) { try { System.out.println("In try"); return; } catch (Exception e) { System.out.println("In catch"); } finally { System.out.println("In finally"); } } }

Q.445Hard

Which of the following cannot throw a checked exception without being declared in throws clause?

Q.446Medium

What is the output of exception chaining in Java?

Q.447Medium

Which method is used to get the exception that caused the current exception in Java?

Q.448Easy

What happens when an unchecked exception is not caught?

Q.449Easy

Which exception is thrown when attempting to access an index outside the bounds of an array?

Q.450Hard

What is the execution order in try-catch-finally for nested exception handling?

Q.451Easy

Consider a method signature: public void readFile() throws IOException. Which statement is correct?

Q.452Hard

What is suppressed exception in Java (introduced in Java 7)?

Q.453Easy

Which of the following statements about try-catch-finally blocks is correct?

Q.454Easy

What is the output of the following code? public class ExceptionTest { public static void main(String[] args) { try { int x = ; } catch (ArithmeticException e) { System.out.println("Caught"); } finally { System.out.println("Finally"); } } }

Q.455Easy

What will be the output? public class Test { public static void main(String[] args) { try { throw new Exception("Test"); } catch (Exception e) { System.out.println("1"); } catch (Exception e) { System.out.println("2"); } } }

Q.456Medium

Which exception is thrown when a thread tries to acquire a monitor that is already locked?

Q.457Medium

Consider the following code. What will be printed? public class FinallyTest { public static int getValue() { try { return 10; } finally { System.out.println("Finally"); } } public static void main(String[] args) { System.out.println(getValue()); } }

Q.458Medium

Which of the following statements is true regarding exception constructors?

Q.459Medium

What is the output of multi-level exception chaining? public class ChainTest { public static void main(String[] args) { try { try { throw new IOException("IO Error"); } catch (IOException e) { throw new RuntimeException("Runtime Error", e); } } catch (RuntimeException e) { System.out.println(e.getCause().getClass().getSimpleName()); } } }

Q.460Medium

Which of the following best describes a custom exception in Java?