Hi
Java Ranchers,
first of all, HAPPY NEW YEAR to all...
I have seen the following question in this forum, some time back. But, when i read about this topic i got one doubt.
CODE:
public class
test {
public static void main(
String args[])
{
Derived d = new Derived();
}
}
class Base{
Base(){
print();
}
void print(){
System.out.println("in Base Class");
}
}
class Derived extends Base{
String temp = "temp";
void print(){
System.out.println("in Drived Class "+temp);
}
}
The output for this code is : "in Drived Class null"
Now i have read that, the instance variables and the instance methods can not be accessed, until the super constructor is completed. So, the value of the string is 'null' which can not be accessed until, the 'Base' constructor is completed. But then, how come the method 'print' in Derived class is accessible, even before the completion of 'Base' constructor.
Thanks in advance,
James.