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

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

Q.22Easy

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

Q.23Medium

Which statement about multiple catch blocks is TRUE?

Q.24Medium

Analyze the code: public void process() throws IOException { try { readFile(); } catch (FileNotFoundException e) { // handle } } What is the issue here?

Q.25Medium

What happens if you throw an exception inside the finally block?

Q.26Medium

Consider the code: try (FileReader fr = new FileReader("file.txt")) { // use fr } catch (IOException e) { // handle } What will happen to 'fr' after the try block?

Q.27Medium

Which of these is NOT a correct way to handle checked exceptions?

Q.28Medium

What is the output? public class Test { public static void main(String[] args) { int x = 0; try { x = 5; System.out.println(x / 0); x = 10; } catch (ArithmeticException e) { x = 15; } finally { System.out.println(x); } } }

Q.29Medium

What will happen if a finally block contains a return statement?

Q.30Medium

Analyze the code: try { // code } catch (IOException | SQLException e) { // handle } What is this syntax called?

Q.31Medium

What is the difference between throw and throws?

Q.32Medium

Consider this code: public static void main(String[] args) { try { System.out.println("A"); return; } finally { System.out.println("B"); } } What is the output?

Q.33Medium

Which of the following cannot be used with try-with-resources?

Q.34Hard

What will be printed? public class ExceptionTest { public static void main(String[] args) { try { testMethod(); } catch (Exception e) { System.out.println("Caught"); } } public static void testMethod() { try { throw new RuntimeException("Error"); } finally { System.out.println("Finally"); } } }

Q.35Medium

Which statement is TRUE about exception propagation in Java?

Q.36Easy

Which of the following exceptions is a checked exception in Java?

Q.37Easy

What is the correct syntax for declaring multiple exceptions in a method signature?

Q.38Easy

In Java exception handling, what is the purpose of the finally block?

Q.39Medium

What will be the behavior if an exception is thrown in the finally block?

Q.40Medium

Which statement about try-with-resources (introduced in Java 7) is correct?