System.out.println("name is "+name);
If a reference is created for the above class without allocating memory ie Student s & not
and its method is called s.display(), why the null value or the default values(in general) are not passed ?
java throws exception "s might not have been initialised".
Jesper Young wrote:Only member variables are initialized with default values (null in the case of a reference variable). Local variables (inside a method) must be explicitly initialized, and if you don't, you'll get a compiler error "variable might not have been initialized".
I, now have understood it clearly .