Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Exceptions + java

Total questions: 11

Worksheet time: 6mins

Name
Class
Date
1.

What is an exception?

a)

Run-time error occurred during the execution of a program

b)

Compile time error of a program

c)

Simply a Syntax or Semantic Error

d)

None of these

2.

try block may or may not be followed by catch block(s)

a)

True

b)

False

3.

Exception is a _________.

a)

Class

b)

Interface

c)

Abstract class

d)

Other

4.

What is the advantage of Exception Handling?

a)

To avoid abnormal termination of a program

b)

To find out errors

c)

To Debug program

d)

None of these

5.

Which of the following statements should be used to import Exception Class?

a)

import java.io.*

b)

import java.lang.*

c)

import java.util.*

d)

import java.lang.Exception.*

6.

How can you create User-defined Exceptions?

a)

using 'throw' keyword

b)

using 'throws' keyword

c)

using 'finally' keyword

d)

using 'throwable' keyword

7.

Identify superclass of all exception classes

a)

Exception

b)

Throwable

c)

RuntimeException

d)

IOException

8.

Choose an exception if attempt to divide number by zero


int number = 89 / 0;

System.out.println("The answer is " + number);

a)

ArithmeticException

b)

NullPointerException

c)

NumberFormatException

d)

ArrayIndexOutOfBoundException

9.

Choose the CORRECT exception


String department="JTMK";

Integer no=Integer.parseInt(department);

a)

ArithmeticException

b)

NullPointerException

c)

NumberFormatException

d)

ArrayIndexOutOfBoundsException

10.

In nested try-catch block, if the inner catch block gets executed, then______________

a)

Program stops immediately

b)

Outer catch block also executes

c)

Compiler jumps to the outer catch block and executes remaining statements of the main() function

d)

Compiler executes remaining statements of outer try-catch block and then the main() function

11.

Which of the following statements are correct about catch block?

i. It must be placed immediately after the try block

ii. It can have more than one parameter

iii. There must be only one catch handler for every try block

iv. There can be multiple catch handler for a try block

a)

i, iii

b)

i, ii, iii

c)

i, iv

d)

i, ii