Array Output 2
public class JavaRecipe{
public static void main(String[] jr){
int[] arr = new int[0];
System.out.println(arr.length); //line 1
arr[0] = 10; //line 2
Ststem.out.println(arr[0]); //line 3
}
}
1. Compilation error at Line 1 : size of array cant be 0
2. Runntime error at Line 2 : ArrayIndexOutOfBoundException
3. Compiles fine and gives output as 0 10
4. Runntime error at line 1 & 3 : NullPointerException
Comments
Post a Comment