Qtr No. 213, New Town Yehlanka Indore 454775
What will be the output of the below code?
public class Demo {
public static void main(String[] args) {
int[] a = { 10, 20, 30};
int b = 0;
try { b = a[2];
System.out.println("Value of b=" + b);// Statement 1
String str = args[0];
System.out.println("Length of the string is:=" + str.length());//Statement 2
} catch (ArithmeticException|NullPointerException ec){
System.out.println("An exception has occurred");//Statement 3
} finally {
System.out.println("In the finally block");// Statement 4
}
System.out.println("Exception handled successfully");// Statement 5
} }
Runtime Exception: Null Pointer Exception and no other output
Statement 1, 4 and Runtime Exception: ArrayIndexOutOfBoundsException
Statements 1,3,4 and 5 will be part of the output
Statements 1,2,4 and 5 will be part of the output
To get all Infosys Certified L1 Junior Java Programmer Exam questions Join Group https://bit.ly/infy_premium_group
We're passionate about offering best placement materials and courses!! A one stop place for Placement Materials. We daily post Offcampus updates and Placement Materials.
Qtr No. 213, New Town Yehlanka Indore 454775
admin@prepflix.in