Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Exception Handling in Java-10

Total questions: 62

Worksheet time: 31mins

Name
Class
Date
1.
When does Exceptions in Java arises in code sequence?
a)
Run Time
b)
Compilation Time
c)
Can Occur Any Time
d)
None of the mentioned
2.
Which of these keywords is not a part of exception handling?
a)
try
b)
finally
c)
thrown
d)
catch
3.
Which of these keywords must be used to monitor for exceptions?
a)
try
b)
finally
c)
throw
d)
catch
4.
Which of these keywords must be used to handle the exception thrown by try block in some rational manner?
a)
try
b)
finally
c)
throw
d)
catch
5.
Which of these keywords is used to manually throw an exception?
a)
try
b)
finally
c)
throw
d)
catch
6.

What will be the output of the following Java program?

https://gyazo.com/b6f87b2a6cf67fa9a23985bd4d7a64ac

a)

Hello

b)

World

c)

HelloWorld

d)

Hello World

7.

What will be the output of the following Java program? https://gyazo.com/e0ce395823dc7929fddba189d4887846

a)

A

b)

B

c)

Compilation Error

d)

Runtime Error

8.

What will be the output of the following Java program? https://gyazo.com/ba3708c684b5501148668aea32352be5

a)

A

b)

B

c)

AC

d)

BC

9.

What will be the output of the following Java program? https://gyazo.com/da987a7c8ad7c9254d844e325fa8435a

a)

1

b)

5

c)

Compilation Error

d)

Runtime Error

10.
Which of the following keywords is used for throwing exception manually?
a)
finally
b)
try
c)
throw
d)
catch
11.
Which of the following classes can catch all exceptions which cannot be caught?
a)
RuntimeException
b)
Error
c)
Exception
d)
ParentException
12.
Which of the following is a super class of all exception type classes?
a)
Catchable
b)
RuntimeExceptions
c)
String
d)
Throwable
13.
Which of the following operators is used to generate instance of an exception which can be thrown using throw?
a)
thrown
b)
alloc
c)
malloc
d)
new
14.
Which of the following keyword is used by calling function to handle exception thrown by called function?
a)
throws
b)
throw
c)
try
d)
catch
15.
Which of the following handles the exception when a catch is not used?
a)
finally
b)
throw handler
c)
default handler
d)
java run time system
16.
Which part of code gets executed whether exception is caught or not?
a)
finally
b)
try
c)
catch
d)
throw
17.
Which of the following should be true of the object thrown by a thrown statement?
a)
Should be assignable to String type
b)
Should be assignable to Exception type
c)
Should be assignable to Throwable type
d)
Should be assignable to Error type
18.
At runtime, error is recoverable.
a)
True
b)
False
19.
Which of these is a super class of all exceptional type classes?
a)
String
b)
RuntimeExceptions
c)
Throwable
d)
Cacheable
20.
Which of these class is related to all the exceptions that can be caught by using catch?
a)
Error
b)
Exception
c)
RuntimeExecption
d)
All of the mentioned
21.
Which of these class is related to all the exceptions that cannot be caught?
a)
Error
b)
Exception
c)
RuntimeExecption
d)
All of the mentioned
22.
Which of these handles the exception when no catch is used?
a)
Default handler
b)
finally
c)
throw handler
d)
Java run time system
23.
What exception thrown by parseInt() method?
a)
ArithmeticException
b)
ClassNotFoundException
c)
NullPointerException
d)
NumberFormatException
24.

What will be the output of the following Java code?

https://gyazo.com/04d01e3fae074ad3d1cacc7f4d132f2c

a)

Hello

b)

World

c)

Compilation Error

d)

First Exception then World

25.

What will be the output of the following Java code?

https://gyazo.com/822398f0d42290e8b3ec962ad2002d04

a)

-1

b)

0

c)

-10

d)

-101

26.

What will be the output of the following Java code?

https://gyazo.com/6370d9dd5271eb05899ce4050c875d1e

a)

Hello

b)

World

c)

Compilation Error

d)

First Exception then World

27.
Which of these keywords is used to generate an exception explicitly?
a)
try
b)
finally
c)
throw
d)
catch
28.
Which of these class is related to all the exceptions that are explicitly thrown?
a)
Error
b)
Exception
c)
Throwable
d)
Throw
29.
Which of these operator is used to generate an instance of an exception than can be thrown by using throw?
a)
new
b)
malloc
c)
alloc
d)
thrown
30.
Which of these keywords is used to by the calling function to guard against the exception that is thrown by called function?
a)
try
b)
throw
c)
throws
d)
catch
31.

What will be the output of the following Java code?

https://gyazo.com/122b5ae3f5ed272fdc2ca337c239f9ea

a)

TypeA

b)

TypeB

c)

Compile Time Error

d)

0TypeB

32.

What will be the output of the following Java code?

https://gyazo.com/ddd50d6b342f4b7da64afd377e3f1dbb

a)

A

b)

B

c)

Hello

d)

Runtime Exception

33.

What will be the output of the following Java code?

https://gyazo.com/409e6b5787fcdf818b14a347fcf2d8f8

a)

Finally

b)

Compilation fails

c)

The code runs with no output

d)

An exception is thrown at runtime

34.

What will be the output of the following Java code?

https://gyazo.com/f6ab94834eaa28f9ecd03d4fb5081011

a)

The program will not compile because no exceptions are specified

b)

The program will not compile because no catch clauses are specified

c)

Hello world

d)

Hello world Finally executing

35.
Which of these clause will be executed even if no exceptions are found?
a)
throws
b)
finally
c)
throw
d)
catch
36.
A single try block must be followed by which of these?
a)
finally
b)
catch
c)
finally & catch
d)
none of the mentioned
37.
Which of these exceptions handles the divide by zero error?
a)
ArithmeticException
b)
MathException
c)
IllegalAccessException
d)
IllegarException
38.
Which of these exceptions will occur if we try to access the index of an array beyond its length?
a)
ArithmeticException
b)
ArrayException
c)
ArrayIndexException
d)
ArrayIndexOutOfBoundsException
39.

What will be the output of the following Java code?

https://gyazo.com/46ce2ce1925490c9caa89c7098f103bc

a)

0

b)

1

c)

Compilation Error

d)

Runtime Error

40.

What will be the output of the following Java code?

https://gyazo.com/ea9dc12264250875dd82abb15a02d979

a)

A

b)

B

c)

Compilation Error

d)

Runtime Error

41.

What will be the output of the following Java code?

https://gyazo.com/92a3b3308b785bc63257d2a39d767b6d

a)

A

b)

B

c)

AB

d)

BA

42.

What will be the output of the following Java code?

https://gyazo.com/162bf65da7d91ea95c1bf6be3b658733

a)

TypeA

b)

TypeB

c)

Compilation Error

d)

Runtime Error

43.
What is the use of try & catch?
a)
It allows us to manually handle the exception
b)
It allows to fix errors
c)
It prevents automatic terminating of the program in cases when an exception occurs
d)
All of the mentioned
44.
Which of these keywords are used for the block to be examined for exceptions?
a)
try
b)
catch
c)
throw
d)
check
45.
Which of these keywords are used for the block to handle the exceptions generated by try block?
a)
try
b)
catch
c)
throw
d)
check
46.
Which of these keywords are used for generating an exception manually?
a)
try
b)
catch
c)
throw
d)
check
47.
Which of these statements is incorrect?
a)
try block need not to be followed by catch block
b)
try block can be followed by finally block instead of catch block
c)
try can be followed by both catch and finally block
d)
try need not to be followed by anything
48.

What will be the output of the following Java code?

https://gyazo.com/cbb048edec50770805f4bbc8064edfbf

a)

Hello

b)

World

c)

HelloWOrld

d)

Compilation Error

49.

What will be the output of the following Java code?

https://gyazo.com/1fb5a4f0fed3a2fd59848cf9501dfca5

a)

Hello

b)

World

c)

HelloWOrld

d)

Compilation Error

50.

What will be the output of the following Java code?

https://gyazo.com/e4a0167efd7a13e8103c0f98a0037e05

a)

Hello

b)

World

c)

HelloWOrld

d)

Compilation Error

51.

What will be the output of the following Java code?

https://gyazo.com/24d575a84ce543b7a8fe8bdbf84cab63

a)

Hello

b)

World

c)

HelloWOrld

d)

Compilation Error

52.

What will be the output of the following Java code?

https://gyazo.com/d8152578df4c3510ee7e48722ac903b8

a)

Hello

b)

World

c)

HelloWOrld

d)

WorldWorld

53.
Which of these classes is used to define exceptions?
a)
Exception
b)
Throwable
c)
Abstract
d)
System
54.
Which of these methods return description of an exception?
a)
getException()
b)
getMessage()
c)
obtainDescription()
d)
obtainException()
55.
Which of these methods is used to print stack trace?
a)
obtainStackTrace()
b)
printStackTrace()
c)
getStackTrace()
d)
displayStackTrace()
56.
Which of these methods return localized description of an exception?
a)

getLocalizedMessage()

b)

getMessage()

c)

obtainLocalizedMessage()

d)

printLocalizedMessage()

57.
Which of these classes is super class of Exception class?
a)
Throwable
b)
System
c)
RunTime
d)
Class
58.

What will be the output of the following Java code?

https://gyazo.com/8e28327f0082c4287698fb6a25918618

a)

3

b)

Exception

c)

Runtime Error

d)

Compilation Error

59.

What will be the output of the following Java code?

https://gyazo.com/6ff20a3e558d7251034b34c90965b773

a)

3

b)

Exception

c)

Runtime Error

d)

Compilation Error

60.

What will be the output of the following Java code?

https://gyazo.com/f880ecc7b308e01a769d4bf2f26356f1

a)

A

b)

B

c)

Compilation Error

d)

Runtime Error

61.

What will be the output of the following Java code?

https://gyazo.com/04b3ab411f0ceb1f6ecae532cbcaeef0

a)

3

b)

Exception

c)

Runtime Error

d)

Compilation Error

62.

What will be the output of the following Java code?

https://gyazo.com/c3a2cf5b5b3233c502f7b068737d7976

a)

TypeA

b)

TypeB

c)

Compilation Error

d)

Runtime Error