What is the result?

Given:
public class MyFor3 {
public static void main(String [] args) {
int [] xx = null;
System.out.println(xx);
}
}
What is the result?

Given:
public class MyFor3 {
public static void main(String [] args) {
int [] xx = null;
System.out.println(xx);
}
}
What is the result?

A.
null

B.
compilation fails

C.
Java.lang.NullPointerException

D.
0

Explanation:
An array variable (here xx) can very well have the null value.
Note:
Null is the reserved constant used in Java to represent a void reference i.e a pointer to nothing.
Internally it is just a binary 0, but in the high level Java language, it is a magic constant, quite
distinct from zero, that internally could have any representation.



Leave a Reply 0

Your email address will not be published. Required fields are marked *