Skip to main content

Exceptions — Part 1 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Exceptions — Part 1 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.

Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40

Verified Practice Questions

Interactive test mode with detailed academic worked solutions

Live Progress | 0/40 answered
✓ 0 correct ✗ 0 wrong 0% score
Question 1 of 40
★ FPSC ★ PPSC

What is the result of the following code snippet? try { throw new NullPointerException(); } catch (ArithmeticException e) { System.out.println("Arithmetic Exception!"); } catch (NullPointerException e) { System.out.println("NullPointerException!"); }

Question 2 of 40
★ FPSC ★ PPSC

In which of the following package Exception class exist?

Question 3 of 40
★ FPSC ★ PPSC

Given the following piece of code: class SalaryCalculationException extends Exception{} class Person{ public void calculateSalary() throws SalaryCalculationException{ //... throw new SalaryCalculationException(); //... } } class Company{ public void paySalaries(){ new Person().calculateSalary(); } } Which of the following statements is correct? 1. This code will compile without any problems. 2. This code will compile if in method paySalaries() we return a boolean in stead of void. 3. This code will compile if we add a try-catch block in paySalaries(). 4. This code will compile if we add throws SalaryCalculationException in the signature of method paySalaries().

Question 4 of 40
★ FPSC ★ PPSC

What will be the output? class MyClass{ public String test(){ try{ System.out.print("One"); return ""; } finally{ System.out.print("Two"); } } } public class Test{ public static void main(String args[]){ MyClass m = new MyClass(); m.test(); } }

Question 5 of 40
★ FPSC ★ PPSC

What will be the result after compiling this code? class SuperClass{ public int doIt(String str, Integer... data)throws Exception{ String signature = "(String, Integer[])"; System.out.println(str + " " + signature); return 1; } } public class Test extends SuperClass{ public int doIt(String str, Integer... data){ String signature = "(String, Integer[])"; System.out.println("Overridden: " + str + " " +signature); return 0; } public static void main(String... args){ SuperClass sb = new Test(); sb.doIt("hello", 3); } }

Question 6 of 40
★ FPSC ★ PPSC

try{ File f = new File("a.txt"); }catch(Exception e){ }catch(IOException io){ } Is this code create new file name a.txt ?

Question 7 of 40
★ FPSC ★ PPSC

What is the output for the below code? import java.io.FileNotFoundException; class A{ public void printName() throws FileNotFoundException{ System.out.println("Value-A"); } } class B extends A{ public void printName() throws NullPointerException{ System.out.println("Name-B"); } } public class Test{ public static void main (String[] args) throws Exception{ A a = new B(); a.printName(); } }

Question 8 of 40
★ FPSC ★ PPSC

What will be the result of executing the following code? public class Test{ public void divide(int a, int b){ try{ int c = a / b; }catch(Exception e){ System.out.print("Exception "); }finally{ System.out.println("Finally"); } public static void main(String args[]){ Test t = new Test(); t.divide(0,3); } }

Question 9 of 40
★ FPSC ★ PPSC

Which of the below statement is/are true about Error? A. An Error is a subclass of Throwable. B. An Error is a subclass of Exception. C. Error indicates serious problems that a reasonable application should not try to catch. D. An Error is a subclass of IOException.

Question 10 of 40
★ FPSC ★ PPSC

What is an exception in Java?

Question 11 of 40
★ FPSC ★ PPSC

Which keyword is used to handle exceptions in Java?

Question 12 of 40
★ FPSC ★ PPSC

What is the purpose of the "try" block in exception handling?

Question 13 of 40
★ FPSC ★ PPSC

In Java, can a method declare multiple exceptions using the "throws" keyword?

Question 14 of 40
★ FPSC ★ PPSC

What is the purpose of the "catch" block in exception handling?

Question 15 of 40
★ FPSC ★ PPSC

In Java, can a "catch" block catch multiple exceptions?

Question 16 of 40
★ FPSC ★ PPSC

What is the purpose of the "throw" keyword in Java exception handling?

Question 17 of 40
★ FPSC ★ PPSC

In Java, can a method throw any checked exception without declaring it using "throws"?

Question 18 of 40
★ FPSC ★ PPSC

What is the purpose of the "throws" keyword in Java method declaration?

Question 19 of 40
★ FPSC ★ PPSC

What is the result of the following code snippet? try { int[] arr = new int[5]; int value = arr[10]; } catch (ArrayIndexOutOfBoundsException e) { System.out.println("Exception Caught!"); }

Question 20 of 40
★ FPSC ★ PPSC

In Java, which type of exceptions are checked at compile-time?

Question 21 of 40
★ FPSC ★ PPSC

What is the result of the following code snippet? try { int num = 10 / 0; } catch (ArithmeticException e) { System.out.println("Arithmetic Exception!"); } catch (Exception e) { System.out.println("Exception!"); }

Question 22 of 40
★ FPSC ★ PPSC

In Java, which type of exceptions are unchecked at compile-time?

Question 23 of 40
★ FPSC ★ PPSC

What is the result of the following code snippet? try { String str = null; System.out.println(str.length()); } catch (NullPointerException e) { System.out.println("NullPointerException!"); } catch (Exception e) { System.out.println("Exception!"); }

Question 24 of 40
★ FPSC ★ PPSC

In Java, can a "finally" block be used without a "try-catch" block?

Question 25 of 40
★ FPSC ★ PPSC

What is the purpose of the "finally" block in Java exception handling?

Question 26 of 40
★ FPSC ★ PPSC

In Java, can a "finally" block be used without a "catch" block?

Question 27 of 40
★ FPSC ★ PPSC

What is the result of the following code snippet? try { int[] arr = new int[5]; int value = arr[2]; } catch (NullPointerException e) { System.out.println("NullPointerException!"); } finally { System.out.println("Finally Block!"); }

Question 28 of 40
★ FPSC ★ PPSC

In Java, can a "catch" block catch exceptions of a superclass type?

Question 29 of 40
★ FPSC ★ PPSC

What is the result of the following code snippet? try { int result = 10 / 0; } catch (ArithmeticException e) { System.out.println("Arithmetic Exception!"); } finally { System.out.println("Finally Block!"); }

Question 30 of 40
★ FPSC ★ PPSC

In Java, can a method declare both "throws" and "throw" statements?

Question 31 of 40
★ FPSC ★ PPSC

What is the result of the following code snippet? try { String str = "Java"; int num = Integer.parseInt(str); } catch (NumberFormatException e) { System.out.println("NumberFormatException!"); } catch (Exception e) { System.out.println("Exception!"); } finally { System.out.println("Finally Block!"); }

Question 32 of 40
★ FPSC ★ PPSC

In Java, can a method declare "throws" for a checked exception that is not thrown in the method body?

Question 33 of 40
★ FPSC ★ PPSC

In Java, can a "finally" block have a "return" statement?

Question 34 of 40
★ FPSC ★ PPSC

What is the result of the following code snippet? try { int[] arr = new int[5]; int value = arr[10]; } catch (ArrayIndexOutOfBoundsException e) { System.out.println("Exception Caught!"); } finally { System.out.println("Finally Block!"); }

Question 35 of 40
★ FPSC ★ PPSC

In Java, can a "try" block have multiple "catch" blocks?

Question 36 of 40
★ FPSC ★ PPSC

What is the result of the following code snippet? try { throw new ArithmeticException(); } catch (Exception e) { System.out.println("Exception!"); } catch (ArithmeticException e) { System.out.println("Arithmetic Exception!"); }

Question 37 of 40
★ FPSC ★ PPSC

In Java, can a "catch" block catch exceptions of a subclass type before catching exceptions of a superclass type?

Question 38 of 40
★ FPSC ★ PPSC

What is the result of the following code snippet? try { throw new RuntimeException(); } catch (RuntimeException e) { System.out.println("Runtime Exception!"); } catch (Exception e) { System.out.println("Exception!"); }

Question 39 of 40
★ FPSC ★ PPSC

The class at the top of exception class hierarchy is .................

Question 40 of 40
★ FPSC ★ PPSC

Exception generated in try block is caught in ........... block.

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 Examiner's Advisory for Programming & Software Development

In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →