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

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

Q.122Easy

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

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

Q.124Easy

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

Q.125Easy

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

Q.126Easy

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

Q.127Easy

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

Q.128Easy

What happens when an unchecked exception is not caught?

Q.129Easy

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

Q.130Easy

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

Q.131Easy

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

Q.132Easy

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

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

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

Q.135Easy

Which of the following is NOT a subclass of Throwable?

Q.136Easy

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

Q.137Easy

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

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

Q.139Easy

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

Q.140Easy

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"); }