Given the code. What is the result when this program is executed?public class Test{ static int x[]; static{ x[0] = 1; } public static void main(String args[]){ }} IllegalStateException is thrown ArrayIndexOutOfBoundsException is thrown None of these ExceptionInInitializerError is thrown StackOverflowException is thrown TRUE ANSWER : ? YOUR ANSWER : ?
What happen in case of multiple catch blocks? None of these The superclass exception must be caught first. The superclass exception cannot caught first. Either super or subclass can be caught first. TRUE ANSWER : ? YOUR ANSWER : ?
Determine output of the following program code?public class Test{ public static void main(String args[]){ int i; try{ i = calculate(); System.out.println(i); }catch(Exception e){ System.out.println("Error occured"); } } static int calculate(){ return (7/2); }} 3.5 Error occured 3 None of these Compilation Error TRUE ANSWER : ? YOUR ANSWER : ?
public class Test{ public static void main(String args[]){ try{ int a = Integer.parseInt("four"); } }}Which exception could be handled by the catch block for above? ArrayIndexOutOfBoundsException None of these NumberFormatException IllegalStateException ClassCastException TRUE ANSWER : ? YOUR ANSWER : ?
Which keyword is used to specify the exception thrown by method? finally throws catch throw TRUE ANSWER : ? YOUR ANSWER : ?
Which exception is thrown when divide by zero statement executes? ArithmeticException NullPointerException None of these NumberFormatException TRUE ANSWER : ? YOUR ANSWER : ?
Which exception is thrown when an array element is accessed beyond the array size? None of these ArrayElementOutOfBounds ArrayIndexOutOfBoundsException ArrayIndexOutOfBounds TRUE ANSWER : ? YOUR ANSWER : ?
In which of the following package Exception class exist? java.net java.util java.io java.lang java.file TRUE ANSWER : ? YOUR ANSWER : ?
Predict the output:public class Test{ public static void main(String args[]){ try{ String arr[] = new String[10]; arr = null; arr[0] = "one"; System.out.print(arr[0]); }catch(Exception ex){ System.out.print("exception"); }catch(NullPointerException nex){ System.out.print("null pointer exception"); } }} "exception" is printed. "null pointer exception" is printed. None of these "one" is printed. Compilation fails saying NullPointerException has already been caught. TRUE ANSWER : ? YOUR ANSWER : ?
try{ File f = new File("a.txt");}catch(Exception e){}catch(IOException io){}Is this code create new file name a.txt ? false Compilation Error None of these true TRUE ANSWER : ? YOUR ANSWER : ?