What is the output of this program?
class Array9
{
public static void main(String[] args)
{
int[][] x=new int[3][];
System.out.println(x);
System.out.println(x[0]);
System.out.println(x[0][0]);
}
}
/*
Output:- [[I@4a5ab2
null
NullPointerException
Explanation:- If we are trying to perform any operation on null then we will
get runtime NullPointerException.
*/
{
public static void main(String[] args)
{
int[][] x=new int[3][];
System.out.println(x);
System.out.println(x[0]);
System.out.println(x[0][0]);
}
}
/*
Output:- [[I@4a5ab2
null
NullPointerException
Explanation:- If we are trying to perform any operation on null then we will
get runtime NullPointerException.
*/
0 comments: