I am have the following code
public class Sample {
public static void display(){
System.out.println("Hai Sample");
}
public void displays(){
System.out.println("Hai Sample");
}
}
public class Sample2 {
public static void main(String[] args) {
Sample obj=null;
obj.display();
obj.displays();
}
}
Here, When we use assign null to Sample obj I can access only static method. If I use new operator like Sample obj= new Sample();
I can access both static and non static method.
Here My question is, How object initialization happens here and How null refers Sample object's static methods and why not non static method