Practice high-yield Programming & Software Development MCQs on Exceptions — Part 2 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
🎉 Set complete! All 40 questions answered.
Question 1 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which keyword is used to explicitly throw an exception?
Correct Answer: Option D — throw
Detailed Academic Explanation:
throw is the correct answer to “Which keyword is used to explicitly throw an exception”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which exception is thrown when divide by zero statement executes?
Correct Answer: Option B — ArithmeticException
Detailed Academic Explanation:
ArithmeticException is the correct answer to “Which exception is thrown when divide by zero statement executes”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which keyword is used to specify the exception thrown by method?
Correct Answer: Option B — throws
Detailed Academic Explanation:
throws is the correct answer to “Which keyword is used to specify the exception thrown by method”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following blocks execute compulsorily whether exception is caught or not.
Correct Answer: Option A — finally
Detailed Academic Explanation:
finally is the correct answer to “Which of the following blocks execute compulsorily whether exception is caught or not.”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What happen in case of multiple catch blocks?
Correct Answer: Option C — The superclass exception cannot caught first.
Detailed Academic Explanation:
The superclass exception cannot caught first. is the correct answer to “What happen in case of multiple catch blocks”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which exception is thrown when an array element is accessed beyond the array size?
Correct Answer: Option B — ArrayIndexOutOfBoundsException
Detailed Academic Explanation:
ArrayIndexOutOfBoundsException is the correct answer to “Which exception is thrown when an array element is accessed beyond the array size”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the following program code? public class Test{ public static void main(String args[]){ try{ int i; return; } catch(Exception e){ System.out.print("inCatchBlock"); } finally{ System.out.println("inFinallyBlock"); } } }
Correct Answer: Option C — inFinallyBlock
Detailed Academic Explanation:
inFinallyBlock is the correct answer to “What is the output of the following program code? public class Test{ public static void main(String args[]){ try{ int i; return; } catch(Exception e){ System.out.print("inCatchBlock"); } finally{ System.out.println("inFinallyBlock"); } } }”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following piece of code: class Person{ public void talk() {} } public class Test{ public static void main(String args[]){ Person p = null; try{ p.talk(); } catch(NullPointerException e){ System.out.print("There is a NullPointerException. "); } catch(Exception e){ System.out.print("There is an Exception. "); } System.out.print("Everything went fine. "); } }
Correct Answer: Option A — There is a NullPointerException. Everything went fine.
Detailed Academic Explanation:
There is a NullPointerException. Everything went fine. is the correct answer to “What will be the output of the following piece of code: class Person{ public void talk() {} } public class Test{ public static void main(String args[]){ Person p = null; try{ p.talk(); } catch(NullPointerException e){ System.out.print("There is a NullPointerException. "); } catch(Exception e){ System.out.print("There is an Exception. "); } System.out.print("Everything went fine. "); } }”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Determine output of the following program code? public class Test{ public static void main(String args[]){ int i; try{ i = calculate(); System.out.println(i); }catch(Exception e){ System.out.println("Error occured"); } } static int calculate(){ return (7/2); } }
Correct Answer: Option A — 3
Detailed Academic Explanation:
3 is the correct answer to “Determine output of the following program code? public class Test{ public static void main(String args[]){ int i; try{ i = calculate(); System.out.println(i); }catch(Exception e){ System.out.println("Error occured"); } } static int calculate(){ return (7/2); } }”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
public class Test{ public static void main(String args[]){ try{ int a = Integer.parseInt("four"); } } } Which exception could be handled by the catch block for above?
Correct Answer: Option B — NumberFormatException
Detailed Academic Explanation:
NumberFormatException is the correct answer to “public class Test{ public static void main(String args[]){ try{ int a = Integer.parseInt("four"); } } } Which exception could be handled by the catch block for above”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Predict the output: public class Test{ public static void main(String args[]){ try{ String arr[] = new String[10]; arr = null; arr[0] = "one"; System.out.print(arr[0]); }catch(Exception ex){ System.out.print("exception"); }catch(NullPointerException nex){ System.out.print("null pointer exception"); } } }
Correct Answer: Option D — Compilation fails saying NullPointerException has already been caught.
Detailed Academic Explanation:
Compilation fails saying NullPointerException has already been caught. is the correct answer to “Predict the output: public class Test{ public static void main(String args[]){ try{ String arr[] = new String[10]; arr = null; arr[0] = "one"; System.out.print(arr[0]); }catch(Exception ex){ System.out.print("exception"); }catch(NullPointerException nex){ System.out.print("null pointer exception"); } } }”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Given the code. What is the result when this program is executed? public class Test{ static int x[]; static{ x[0] = 1; } public static void main(String args[]){ } }
Correct Answer: Option B — ExceptionInInitializerError is thrown
Detailed Academic Explanation:
ExceptionInInitializerError is thrown is the correct answer to “Given the code. What is the result when this program is executed? public class Test{ static int x[]; static{ x[0] = 1; } public static void main(String args[]){ } }”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the result if NullPointerException occurs at line 2? try{ //some code goes here } catch(NullPointerException ne){ System.out.print("1 "); } catch(RuntimeException re){ System.out.print("2 "); } finally{ System.out.print("3"); }
Correct Answer: Option D — 1 3
Detailed Academic Explanation:
1 3 is the correct answer to “What will be the result if NullPointerException occurs at line 2? try{ //some code goes here } catch(NullPointerException ne){ System.out.print("1 "); } catch(RuntimeException re){ System.out.print("2 "); } finally{ System.out.print("3"); }”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the result after the class Test execution? class A{ public void doA(){ B b = new B(); b.dobB(); System.out.print("doA"); } } class B{ public void dobB(){ C c = new C(); c.doC(); System.out.print("doB"); } } class C{ public void doC(){ if(true) throw new NullPointerException(); System.out.print("doC"); } } public class Test{ public static void main(String args[]){ try{ A a = new A(); a.doA(); }catch(Exception ex){ System.out.print("error"); } } }
Correct Answer: Option D — "error" is printed
Detailed Academic Explanation:
"error" is printed is the correct answer to “What will be the result after the class Test execution? class A{ public void doA(){ B b = new B(); b.dobB(); System.out.print("doA"); } } class B{ public void dobB(){ C c = new C(); c.doC(); System.out.print("doB"); } } class C{ public void doC(){ if(true) throw new NullPointerException(); System.out.print("doC"); } } public class Test{ public static void main(String args[]){ try{ A a = new A(); a.doA(); }catch(Exception ex){ System.out.print("error"); } } }”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following should be true of the object thrown by a thrown statement?
Correct Answer: Option C — Should be assignable to Throwable type
Detailed Academic Explanation:
Should be assignable to Throwable type is the correct answer to “Which of the following should be true of the object thrown by a thrown statement”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following keywords is used for throwing exception manually?
Correct Answer: Option C — throw
Detailed Academic Explanation:
throw is the correct answer to “Which of the following keywords is used for throwing exception manually”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these operator is used to generate an instance of an exception than can be thrown by using throw?
Correct Answer: Option A — new
Detailed Academic Explanation:
new is the correct answer to “Which of these operator is used to generate an instance of an exception than can be thrown by using throw”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java code? class Output { public static void main(String args[]) { try { int a = 0; int b = 5; int c = b / a; System.out.print("Hello"); } } }
Correct Answer: Option D — Compilation Error
Detailed Academic Explanation:
Compilation Error is the correct answer to “What will be the output of the following Java code? class Output { public static void main(String args[]) { try { int a = 0; int b = 5; int c = b / a; System.out.print("Hello"); } } }”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these class is related to all the exceptions that cannot be caught?
Correct Answer: Option A — Error
Detailed Academic Explanation:
Error is the correct answer to “Which of these class is related to all the exceptions that cannot be caught”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these classes is used to define exceptions?
Correct Answer: Option A — Exception
Detailed Academic Explanation:
Exception is the correct answer to “Which of these classes is used to define exceptions”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these class is related to all the exceptions that can be caught by using catch?
Correct Answer: Option B — Exception
Detailed Academic Explanation:
Exception is the correct answer to “Which of these class is related to all the exceptions that can be caught by using catch”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java code? class exception_handling { public static void main(String args[]) { try { System.out.print("Hello" + " " + 1 / 0); } finally { System.out.print("World"); } } }
Correct Answer: Option D — First Exception then World
Detailed Academic Explanation:
First Exception then World is the correct answer to “What will be the output of the following Java code? class exception_handling { public static void main(String args[]) { try { System.out.print("Hello" + " " + 1 / 0); } finally { System.out.print("World"); } } }”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these classes is super class of Exception class?
Correct Answer: Option A — Throwable
Detailed Academic Explanation:
Throwable is the correct answer to “Which of these classes is super class of Exception class”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java code? class exception_handling { public static void main(String args[]) { try { int a = args.length; int b = 10 / a; System.out.print(a); try { if (a == 1) a = a / a - a; if (a == 2) { int []c = {1}; c[8] = 9; } } catch (ArrayIndexOutOfBoundException e) { System.out.println("TypeA"); } catch (ArithmeticException e) { System.out.println("TypeB"); } } } Note: Execution command line: $ java exception_handling one two
Correct Answer: Option C — Compilation Error
Detailed Academic Explanation:
Compilation Error is the correct answer to “What will be the output of the following Java code? class exception_handling { public static void main(String args[]) { try { int a = args.length; int b = 10 / a; System.out.print(a); try { if (a == 1) a = a / a - a; if (a == 2) { int []c = {1}; c[8] = 9; } } catch (ArrayIndexOutOfBoundException e) { System.out.println("TypeA"); } catch (ArithmeticException e) { System.out.println("TypeB"); } } } Note: Execution command line: $ java exception_handling one two”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these keywords must be used to monitor for exceptions?
Correct Answer: Option A — try
Detailed Academic Explanation:
try is the correct answer to “Which of these keywords must be used to monitor for exceptions”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java code? public class A { public static void main(String[] args) { try { return; } finally { System.out.println( "Finally" ); } } }
Correct Answer: Option A — Finally
Detailed Academic Explanation:
Finally is the correct answer to “What will be the output of the following Java code? public class A { public static void main(String[] args) { try { return; } finally { System.out.println( "Finally" ); } } }”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following classes can catch all exceptions which cannot be caught?
Correct Answer: Option B — Error
Detailed Academic Explanation:
Error is the correct answer to “Which of the following classes can catch all exceptions which cannot be caught”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java code? class exception_handling { public static void main(String args[]) { try { int i, sum; sum = 10; for (i = -1; i < 3 ;++i) { sum = (sum / i); System.out.print(i); } } catch(ArithmeticException e) { System.out.print("0"); } } }
Correct Answer: Option C — -10
Detailed Academic Explanation:
-10 is the correct answer to “What will be the output of the following Java code? class exception_handling { public static void main(String args[]) { try { int i, sum; sum = 10; for (i = -1; i < 3 ;++i) { sum = (sum / i); System.out.print(i); } } catch(ArithmeticException e) { System.out.print("0"); } } }”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these keywords are used for the block to be examined for exceptions?
Correct Answer: Option A — try
Detailed Academic Explanation:
try is the correct answer to “Which of these keywords are used for the block to be examined for exceptions”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which part of code gets executed whether exception is caught or not?
Correct Answer: Option A — finally
Detailed Academic Explanation:
finally is the correct answer to “Which part of code gets executed whether exception is caught or not”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these keywords must be used to handle the exception thrown by try block in some rational manner?
Correct Answer: Option D — catch
Detailed Academic Explanation:
catch is the correct answer to “Which of these keywords must be used to handle the exception thrown by try block in some rational manner”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java code? class exception_handling { public static void main(String args[]) { try { int a = 1; int b = 10 / a; try { if (a == 1) a = a / a - a; if (a == 2) { int c[] = {1}; c[8] = 9; } } finally { System.out.print("A"); } } catch (Exception e) { System.out.println("B"); } } }
Correct Answer: Option A — A
Detailed Academic Explanation:
A is the correct answer to “What will be the output of the following Java code? class exception_handling { public static void main(String args[]) { try { int a = 1; int b = 10 / a; try { if (a == 1) a = a / a - a; if (a == 2) { int c[] = {1}; c[8] = 9; } } finally { System.out.print("A"); } } catch (Exception e) { System.out.println("B"); } } }”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java code? class Output { public static void main(String args[]) { try { int a = 0; int b = 5; int c = a / b; System.out.print("Hello"); } finally { System.out.print("World"); } } }
Correct Answer: Option C — HelloWOrld
Detailed Academic Explanation:
HelloWOrld is the correct answer to “What will be the output of the following Java code? class Output { public static void main(String args[]) { try { int a = 0; int b = 5; int c = a / b; System.out.print("Hello"); } finally { System.out.print("World"); } } }”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java code? class exception_handling { public static void main(String args[]) { try { throw new NullPointerException ("Hello"); System.out.print("A"); } catch(ArithmeticException e) { System.out.print("B"); } } }
Correct Answer: Option C — Compilation Error
Detailed Academic Explanation:
Compilation Error is the correct answer to “What will be the output of the following Java code? class exception_handling { public static void main(String args[]) { try { throw new NullPointerException ("Hello"); System.out.print("A"); } catch(ArithmeticException e) { System.out.print("B"); } } }”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these methods return localized description of an exception?
Correct Answer: Option A — getLocalizedMessage()
Detailed Academic Explanation:
getLocalizedMessage() is the correct answer to “Which of these methods return localized description of an exception”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java code? class exception_handling { public static void main(String args[]) { try { int a = args.length; int b = 10 / a; System.out.print(a); } catch (ArithmeticException e) { System.out.println("1"); } } } Note : Execution command line : $ java exception_handling
Correct Answer: Option B — 1
Detailed Academic Explanation:
1 is the correct answer to “What will be the output of the following Java code? class exception_handling { public static void main(String args[]) { try { int a = args.length; int b = 10 / a; System.out.print(a); } catch (ArithmeticException e) { System.out.println("1"); } } } Note : Execution command line : $ java exception_handling”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
When does Exceptions in Java arises in code sequence?
Correct Answer: Option A — Run Time
Detailed Academic Explanation:
Run Time is the correct answer to “When does Exceptions in Java arises in code sequence”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java code? class Output { public static void main(String args[]) { try { int a = 0; int b = 5; int c = a / b; System.out.print("Hello"); } catch(Exception e) { System.out.print("World"); } } }
Correct Answer: Option A — Hello
Detailed Academic Explanation:
Hello is the correct answer to “What will be the output of the following Java code? class Output { public static void main(String args[]) { try { int a = 0; int b = 5; int c = a / b; System.out.print("Hello"); } catch(Exception e) { System.out.print("World"); } } }”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java code? class Output { public static void main(String args[]) { try { int a = 0; int b = 5; int c = b / a; System.out.print("Hello"); } catch(Exception e) { System.out.print("World"); } finally { System.out.print("World"); } } }
Correct Answer: Option D — WorldWorld
Detailed Academic Explanation:
WorldWorld is the correct answer to “What will be the output of the following Java code? class Output { public static void main(String args[]) { try { int a = 0; int b = 5; int c = b / a; System.out.print("Hello"); } catch(Exception e) { System.out.print("World"); } finally { System.out.print("World"); } } }”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java code? class exception_handling { public static void main(String args[]) { try { System.out.print("A"); throw new NullPointerException ("Hello"); } catch(ArithmeticException e) { System.out.print("B"); } } }
Correct Answer: Option D — Runtime Exception
Detailed Academic Explanation:
Runtime Exception is the correct answer to “What will be the output of the following Java code? class exception_handling { public static void main(String args[]) { try { System.out.print("A"); throw new NullPointerException ("Hello"); } catch(ArithmeticException e) { System.out.print("B"); } } }”. This question is standard in competitive examination syllabi for Exceptions.
💡Key Conceptual Anchor:Exceptions
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡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.