0
can Reference be NULL or NOt?
if reference can't be null..then Application obj; Application is a class... how the value of obj is NULL???
6 odpowiedzi
+ 4
In your example obj is a reference with type Application. You didn't assign an object to it so its value is null by default. It means that this reference is empty.
+ 4
Wait! What I write is true in Java (you added Java tag too) but a reference cannot be null in C++ but it is possible to reference to an invalid object.
+ 3
Yes.
+ 3
Not right. Can you write a simple test app in Java? Try this in Code Playground:
public class Program
{
public static void main(String[] args) {
String s = null;
System.out.println(s);
}
}
0
so...reference can be null??
0
but i have attended an interview..he told difference between pointer and reference is pointer can be null but reference can not be null