I have a parent class that has some method, in the child class I have overridden the basic class method in class I make the child's purpose and using that object, I want the parental class call method. Is it possible to call the law of that original class? If yes, then how?
Please answer
If you override an original method, its children , Child Objects will always use the overridden version. but; To call you the basic method inside the body of the hair method
to call the public class PolyTest {public static} the keyword super
You can use. Zero main (string ager []) {new hair (). Foo (); }} Class guardian {public void foo () {System.out.println ("I am a guardian"); }} Category Child Parents {@Override Public Zero Foo () {//super.foo (); System.out.println ("I'm a child."); }}
It will print:
I am a child.
Remove the comment line and it will print:
I am a parent.
I am a child.
You should discover the concept of polymorphism.
Comments
Post a Comment