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

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

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

Q.123Easy

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

Q.124Easy

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

Q.125Easy

What is the difference between 'throw' and 'throws' keywords in Java?

Q.126Easy

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

Q.127Easy

What happens when an unchecked exception is not caught?

Q.128Easy

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

Q.129Easy

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

Q.130Easy

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

Q.131Easy

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

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

Which method is used to print the stack trace of an exception?

Q.134Easy

Which of the following is NOT a subclass of Throwable?

Q.135Easy

In Java exception handling, which of the following statements is true about the finally block?

Q.136Easy

What is the output of the following code? int x = 10; try { x = x / 0; } catch (ArithmeticException e) { x = 20; } finally { x = 30; } System.out.println(x);

Q.137Easy

Which exception is thrown when accessing an array element with an invalid index?

Q.138Easy

What is the correct syntax for declaring a method that throws a checked exception?

Q.139Easy

What will happen when the following code is executed? try { int[] arr = {1, 2, 3}; System.out.println(arr[5]); } catch(ArrayIndexOutOfBoundsException e) { System.out.println("Exception caught"); }

Q.140Easy

What is the output of the following code? try { int x = ; } catch(ArithmeticException e) { System.out.println("Caught"); } finally { System.out.println("Finally"); } System.out.println("After");