I\'ve been reading a section on Statics in the SCJP study guide, and it mentions the following :
static methods can\'t be overridden, but they can be r
In rajah9's answer if now we make the two methods static both in parent and child:
public static void getKey() {
System.out.println("I am in and my key is " + key);
}
Two things to note now: Can't use 'this.getClass()' and warning 'The static method getKey() from the type Parent should be accessed in a static way' also
Parent z = new Child();
z.getKey();
Will give the output
I am in class tools.Parent and my key is 3
instead of
I am in class tools.Parent and my key is 33