Exception Handling in Java - Questions and Answers for Java Examinations

(6) When the JVM runs out of memory, which exception will be thrown?
[A] MemoryBoundException
[B] OutOfMemoryError
[C] OutOfRangeException
[D] NullReferenceException

Comment

Answer: Option [B]

When a program is stopped due to lack of memory then OutOfMemoryError is thrown.

(7) In Java programming environment, the throw keyword is used
[A] to generate exception programmatically
[B] to throw exception object
[C] to catch exception object
[D] none of the above

Comment

Answer: Option [A]

In Java throw keyword is used to handle exception programmatically.

DOWNLOAD CURRENT AFFAIRS PDF FROM APP

Article and Schedule Quiz Start Test!
(8) Which exception is thrown by read() method ?
[A] Exception
[B] FileNotFoundException
[C] ReadException
[D] IOException

Comment

Answer: Option [D]

IOException is thrown when I/O operation is failed.

(9) Attempting to access a character that is outside the bounds of a StringBuffer results in a
[A] ArrayIndexOutOfBoundsException
[B] StringOverFlowException
[C] StringException
[D] StringIndexOutOfBoundsException

Comment

Answer: Option [D]
(10) Exception and Error are immediate subclasses of a class called
[A] Object
[B] Throwable
[C] AWT
[D] Panel

Comment

Answer: Option [B]

Throwable is a superclass of all Error and Exception classes.

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