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

Which of the following is a checked exception in Java?

Q.2Medium

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

Q.3Easy

Which exception is thrown when a method receives an illegal or inappropriate argument?

Q.4Easy

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

Q.5Medium

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

Q.6Easy

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

Q.7Medium

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

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

Q.9Hard

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

Q.10Medium

Which of the following exceptions is a checked exception?

Q.11Hard

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

Q.12Medium

Which statement about try-with-resources is TRUE?

Q.13Medium

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

Q.14Easy

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

Q.15Medium

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

Q.16Medium

Which exception hierarchy is correct in Java?

Q.17Medium

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

Q.18Hard

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

Q.19Easy

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

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