iGET

Java Programming - MCQ Practice Questions

Java interviews and campus tests lean heavily on object oriented behaviour rather than API recall. This set covers inheritance and polymorphism, interfaces and abstract classes, the collections framework, exception handling, multithreading, string handling, and JVM basics such as garbage collection. Output based questions are included because they expose the gaps that theory questions hide.

951 questions | 100% Free

Q.401Easy

Can you have a try block without a catch block in Java?

Q.402Medium

What will be the output?
try {
throw new Exception("Test");
} catch(Exception e) {
System.out.println("Caught");
} finally {
System.out.println("Finally");
}

Q.403Easy

Which of the following is NOT a subclass of Throwable in Java?

Q.404Medium

What is the output of multiple catch blocks?
try {
int[] arr = {1, 2, 3};
System.out.println(arr[5]);
} catch(ArrayIndexOutOfBoundsException e) {
System.out.println("Index");
} catch(Exception e) {
System.out.println("Exception");
}

Q.405Easy

Which exception is thrown when trying to access a method of a null object?

Q.406Hard

Analyze the code:
try {
return 5;
} finally {
return 10;
}
What will be returned?

Q.407Medium

Which of the following exceptions is a checked exception?

Q.408Hard

What happens if an exception is thrown in the finally block?

Q.409Medium

Which statement about try-with-resources is TRUE?

Q.410Medium

What is the output?
try {
int x = ;
} catch(Exception e) {
System.out.println("Caught");
} catch(ArithmeticException ae) {
System.out.println("Arithmetic");
}

Q.411Easy

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

Q.412Medium

Analyze this code:
public void test() throws IOException {
// method body
}
What does 'throws' indicate?

Q.413Medium

Which exception hierarchy is correct in Java?

Q.414Medium

What will happen if you don't catch a checked exception?

Q.415Hard

Analyze the nested try-catch:
try {
try {
int x = ;
} catch(NullPointerException e) {
System.out.println("Inner");
}
} catch(ArithmeticException e) {
System.out.println("Outer");
}

Q.416Easy

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

Q.417Easy

In Java exception handling, what is the order of execution in try-finally-catch block?

Q.418Easy

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

Q.419Easy

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.420Medium

Which statement about multiple catch blocks is TRUE?