In Java, can a method declare both "throws" and "throw" statements?
Select an option to see the answer and solution.
What is the result of the following code snippet?
try {
String str = "Java";
int num = Integer.parseInt(str);
} catch (NumberFormatException e) {
System.out.println("NumberFormatException!");
} catch (Exception e) {
System.out.println("Exception!");
} finally {
System.out.println("Finally Block!");
}
Select an option to see the answer and solution.
In Java, can a method declare "throws" for a checked exception that is not thrown in the method body?
Select an option to see the answer and solution.
What is the result of the following code snippet?
try {
throw new NullPointerException();
} catch (ArithmeticException e) {
System.out.println("Arithmetic Exception!");
} catch (NullPointerException e) {
System.out.println("NullPointerException!");
}
Select an option to see the answer and solution.
In Java, can a "finally" block have a "return" statement?
Select an option to see the answer and solution.
What is the result of the following code snippet?
try {
int[] arr = new int[5];
int value = arr[10];
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Exception Caught!");
} finally {
System.out.println("Finally Block!");
}
Select an option to see the answer and solution.
In Java, can a "try" block have multiple "catch" blocks?
Select an option to see the answer and solution.
What is the result of the following code snippet?
try {
throw new ArithmeticException();
} catch (Exception e) {
System.out.println("Exception!");
} catch (ArithmeticException e) {
System.out.println("Arithmetic Exception!");
}
Select an option to see the answer and solution.
In Java, can a "catch" block catch exceptions of a subclass type before catching exceptions of a superclass type?
Select an option to see the answer and solution.
What is the result of the following code snippet?
try {
throw new RuntimeException();
} catch (RuntimeException e) {
System.out.println("Runtime Exception!");
} catch (Exception e) {
System.out.println("Exception!");
}
Select an option to see the answer and solution.
The class at the top of exception class hierarchy is .................
Select an option to see the answer and solution.
In which of the following package Exception class exist?
Select an option to see the answer and solution.
Exception generated in try block is caught in ........... block.
Select an option to see the answer and solution.
Which keyword is used to explicitly throw an exception?
Select an option to see the answer and solution.
Which exception is thrown when divide by zero statement executes?
Select an option to see the answer and solution.
Which keyword is used to specify the exception thrown by method?
Select an option to see the answer and solution.
Which of the following blocks execute compulsorily whether exception is caught or not.
Select an option to see the answer and solution.
What happen in case of multiple catch blocks?
Select an option to see the answer and solution.
Which exception is thrown when an array element is accessed beyond the array size?
Select an option to see the answer and solution.
What is the output of the following program code?
public class Test{
public static void main(String args[]){
try{
int i;
return;
}
catch(Exception e){
System.out.print("inCatchBlock");
}
finally{
System.out.println("inFinallyBlock");
}
}
}
Select an option to see the answer and solution.