Exception Handling MCQs

Exception Handling MCQs

Our team has conducted extensive research to compile a set of Exception Handling MCQs. We encourage you to test your Exception Handling knowledge by answering these # multiple-choice questions provided below.
Simply scroll down to begin!

1: Which block contains a block of program statements within which an exception might occur?

A.   Final

B.   Throw

C.   Catch

D.   Try

2:

If you are inserting any value in the wrong index as shown below, it would result in


1. int a[]=new int[5];

2. a[10]=50;


A.  

ArithmeticException

B.  

 ArrayIndexOutOfBoundsException


C.  

 NumberFormatException


D.  

 NullPointerException


3: Which class is used when a program does not want to handle exceptions?

A.   Try

B.   Final

C.   Catch

D.   Throws

4: Return type of uncaught_exception() is________________.

A.   INT

B.   Char *

C.   Bool

D.   Double

5: The Exception class has two main subclasses?

A.   IOException class And RuntimeException Class

B.   ClassCastException

C.   IOException class

D.   RuntimeException Class

6: A try block can be nested under another try block –

A.   No

B.   Yes

7: How can we restrict a function to throw certain exceptions?

A.   It is not possible in CPP to restrict a function

B.   Defining multiple try and catch block inside a function

C.   Defining function with throw clause

D.   Defining generic function within try block

8: These five keywords are used in try, catch, finally, throw, and throws?

A.   None

B.   Event Handling

C.   String Handling

D.   Exception Handling

9:

Which provides a default exception handler that performs the following tasks?


- Prints out exception description.

- Prints the stack trace (Hierarchy of methods where the exception occurred).

- Causes the program to terminate.


A.  

 jdk

B.  

None

C.  

JRE

D.  

JVM

10: Which allows us to control the normal flow of the program by using exception handling in program?

A.   None

B.   Event Handling

C.   Exception Handling

D.   String Handling

11: If the superclass method does not declare an exception, subclass overridden method cannot declare the checked exception?

A.   True

B.   False

12: Exception handlers are declared with ____________ keyword.

A.   Catch

B.   Try

C.   Finally

D.   Throw

13: Catch handler can have multiple parameters.

A.   False

B.   True

14: We can prevent a function from throwing any exceptions.

A.   False

B.   True

15:

These exceptions are seen in


NullPointerException,

ArrayIndexOutOfBoundsException,

ArithmeticException,

NumberFormatException?


A.  

Unchecked Exception

B.  

 Checked exception And Unchecked exception

C.  

 None

D.  

 Checked Exception

16: Exceptions can be thrown by ________.

A.   The Java Virtual Machine.

B.   Code in a try block.

C.   Calls from a try block to other methods.

D.   All of the above

17: The ____ class represents more serious errors from which your program usually cannot recover.

A.   Error

B.   Throwable

C.   Exception

D.   Menu