The distinction between hiding and overriding has important implications. The version of the overridden method that gets invoked is the one in the subclass. The version of the hidden method that gets invoked depends on whether it is invoked from the superclass or the subclass. Let's look at an example that contains two classes. The first is
Animal, which contains one instance method and one class method:public class Animal {
public static void testClassMethod() {
System.out.println("The class" + " method in Animal.");
}
public void testInstanceMethod() {
System.out.println("The instance " + " method in Animal.");
}
}
The second class, a subclass ofAnimal, is calledCat:
Yuppi
YanıtlaSilNeyyyyyyyyyyyyy
SilAdminim la ben!!!!!!!!!!!
YanıtlaSil