Skip to main content

Exceptions — Part 2 MCQs with Explanations

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
Question 1 of 40
★ FPSC ★ PPSC

Which keyword is used to explicitly throw an exception?

Question 2 of 40
★ FPSC ★ PPSC

Which exception is thrown when divide by zero statement executes?

Question 3 of 40
★ FPSC ★ PPSC

Which keyword is used to specify the exception thrown by method?

Question 4 of 40
★ FPSC ★ PPSC

Which of the following blocks execute compulsorily whether exception is caught or not.

Question 5 of 40
★ FPSC ★ PPSC

What happen in case of multiple catch blocks?

Question 6 of 40
★ FPSC ★ PPSC

Which exception is thrown when an array element is accessed beyond the array size?

Question 7 of 40
★ 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"); } } }

Question 8 of 40
★ 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. "); } }

Question 9 of 40
★ 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); } }

Question 10 of 40
★ 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?

Question 11 of 40
★ 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"); } } }

Question 12 of 40
★ 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[]){ } }

Question 13 of 40
★ 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"); }

Question 14 of 40
★ 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"); } } }

Question 15 of 40
★ FPSC ★ PPSC

Which of the following should be true of the object thrown by a thrown statement?

Question 16 of 40
★ FPSC ★ PPSC

Which of the following keywords is used for throwing exception manually?

Question 17 of 40
★ FPSC ★ PPSC

Which of these operator is used to generate an instance of an exception than can be thrown by using throw?

Question 18 of 40
★ 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"); } } }

Question 19 of 40
★ FPSC ★ PPSC

Which of these class is related to all the exceptions that cannot be caught?

Question 20 of 40
★ FPSC ★ PPSC

Which of these classes is used to define exceptions?

Question 21 of 40
★ FPSC ★ PPSC

Which of these class is related to all the exceptions that can be caught by using catch?

Question 22 of 40
★ 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"); } } }

Question 23 of 40
★ FPSC ★ PPSC

Which of these classes is super class of Exception class?

Question 24 of 40
★ 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

Question 25 of 40
★ FPSC ★ PPSC

Which of these keywords must be used to monitor for exceptions?

Question 26 of 40
★ 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" ); } } }

Question 27 of 40
★ FPSC ★ PPSC

Which of the following classes can catch all exceptions which cannot be caught?

Question 28 of 40
★ 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"); } } }

Question 29 of 40
★ FPSC ★ PPSC

Which of these keywords are used for the block to be examined for exceptions?

Question 30 of 40
★ FPSC ★ PPSC

Which part of code gets executed whether exception is caught or not?

Question 31 of 40
★ FPSC ★ PPSC

Which of these keywords must be used to handle the exception thrown by try block in some rational manner?

Question 32 of 40
★ 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"); } } }

Question 33 of 40
★ 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"); } } }

Question 34 of 40
★ 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"); } } }

Question 35 of 40
★ FPSC ★ PPSC

Which of these methods return localized description of an exception?

Question 36 of 40
★ 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

Question 37 of 40
★ FPSC ★ PPSC

When does Exceptions in Java arises in code sequence?

Question 38 of 40
★ 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"); } } }

Question 39 of 40
★ 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"); } } }

Question 40 of 40
★ 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"); } } }

✓ 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 →