jas preet wrote:Only static variables and methods can be accessed as part of the call to super()
or this(). (Example: super(Animal.NAME) is OK, because NAME is
declared as a static variable.)
I could not get what exactly the statement wants to say. Can any one please elaborate on this.If you can provide me links so that i go on read more on this and get better understanding.
Hello jaspreet,
1> static variables are initialized with default values as soon as class is loaded.
2> static methods get loaded with class as well.
3> static methods can access static members of the class only.
From this you can conclude before you instantiate a class both static variables and methods are available. And this is reason why compiler allows you to access them from a constructor call.