I created 3 classes, the superclass, or grandparent, the parent, and the child.
In my abstract defined superclass, I declared an abstract method that I would be overriding in subsequent classes that inhereted from the superclass.
In my parent class, I redefined the method, keeping the same argument list and name, otherwise known as 'overriding'.
I did the same in the child class, overriding the same method again, with different definition but same argument list and name.. And it let me compile.
I then created a 4th class, which had my
'public static void main(String[] args)' method.
In that method I created class objects for both the parent
and the child classes..
With those objects, I called both the parent and class methods that were overridden from the superclass.
It let me compile.. But when I executed the program,
the PARENT overridden method got called twice..
even though the code was.
<parentclassobject>.overriddenMethod();
<childclassobject>.overriddenMethod();
I need to fix this code by today or tomorrow. Will someone please help me with this.
In my abstract defined superclass, I declared an abstract method that I would be overriding in subsequent classes that inhereted from the superclass.
In my parent class, I redefined the method, keeping the same argument list and name, otherwise known as 'overriding'.
I did the same in the child class, overriding the same method again, with different definition but same argument list and name.. And it let me compile.
I then created a 4th class, which had my
'public static void main(String[] args)' method.
In that method I created class objects for both the parent
and the child classes..
With those objects, I called both the parent and class methods that were overridden from the superclass.
It let me compile.. But when I executed the program,
the PARENT overridden method got called twice..
even though the code was.
<parentclassobject>.overriddenMethod();
<childclassobject>.overriddenMethod();
I need to fix this code by today or tomorrow. Will someone please help me with this.