WorksheetsExceptions + java
Total questions: 11
Worksheet time: 6mins
What is an exception?
Run-time error occurred during the execution of a program
Compile time error of a program
Simply a Syntax or Semantic Error
None of these
try block may or may not be followed by catch block(s)
True
False
Exception is a _________.
Class
Interface
Abstract class
Other
What is the advantage of Exception Handling?
To avoid abnormal termination of a program
To find out errors
To Debug program
None of these
Which of the following statements should be used to import Exception Class?
import java.io.*
import java.lang.*
import java.util.*
import java.lang.Exception.*
How can you create User-defined Exceptions?
using 'throw' keyword
using 'throws' keyword
using 'finally' keyword
using 'throwable' keyword
Identify superclass of all exception classes
Exception
Throwable
RuntimeException
IOException
Choose an exception if attempt to divide number by zero
int number = 89 / 0;
System.out.println("The answer is " + number);
ArithmeticException
NullPointerException
NumberFormatException
ArrayIndexOutOfBoundException
Choose the CORRECT exception
String department="JTMK";
Integer no=Integer.parseInt(department);
ArithmeticException
NullPointerException
NumberFormatException
ArrayIndexOutOfBoundsException
In nested try-catch block, if the inner catch block gets executed, then______________
Program stops immediately
Outer catch block also executes
Compiler jumps to the outer catch block and executes remaining statements of the main() function
Compiler executes remaining statements of outer try-catch block and then the main() function
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
i, iii
i, ii, iii
i, iv
i, ii
