Exception Handling - Java Exam Multiple Choice Questions and Answers

(1) Which of the following does not deal with exceptions?
[A] throws
[B] throw
[C] finalize
[D] finally

Comment

Answer: Option [C]

finalize is a method and all other three are keywords. finalize() method is defined in java.lang.Object class. finalize() method is called to perform specific actions before Garbage collector reclaim the object.

(2) URL throws an exception called
[A] IllegalURLException
[B] URLException
[C] MalformedHostException
[D] MalformedURLException

Comment

Answer: Option [D]

MalformedURLException thrown to indicate when a illegal URL has occured.

DOWNLOAD CURRENT AFFAIRS PDF FROM APP

Article and Schedule Quiz Start Test!
(3) Event handling is done by objects which
[A] Contain code for running an applet
[B] Contain code for creating a window
[C] Contain code for responding to an event generated by a logical input device
[D] Contain code for responding to program generated exceptions

Comment

Answer: Option [C]
(4) Which class is base class for all exceptions?
[A] String
[B] Error
[C] Throwable
[D] RuntimeException

Comment

Answer: Option [C]

Throwbale class is in java.lang and it is the base class for all Exceptions

(5) Java’s exception handling mechanism is meant to handle
[A] only compile time errors
[B] only syntax errors
[C] only runtime errors
[D] both runtime and compile time errors

Comment

Answer: Option [C]

Java’s exception handling mechanism handle errors such as divide integer by zero, ClassNotFound etc.

Take Mock Tests

Missiles Mock Test Start Test!
SSC MTS Mock Test Start Test
IBPS CLERK MOCK TEST Start Test
SSC MTS 2022 JULY 26 Shift 1 (ENGLISH) Start Test!
SSC GD Previous Year Paper 2021 Nov 17 Shift - I (Hindi) Start Test!
SSC CGL Tier - 1 PYP 2022 April 21 Shift- 1 (ENGLISH) Start Test!
MPSC PAPER I MOCK TEST 1 (ENGLISH) Start Test!
IB Security Assistant Mock test 1 (english) Start Test!
UP POLICE CONSTABLE MOCK TEST 1 Start Test!
DELHI POLICE CONSTABLE MOCK TEST 1 (HINDI) Start Test!

Chapters