KaranGupta
asked on
Overriding method
Hi
In Java I have written the code
Here I have declared method Display() in the ChildClass class. Is this the way we can override a method. Aren't we using any keyword like override for overriding the method?
In Java I have written the code
class BaseClass
{
public void Display()
{
System.out.println("This is the method of base class");
}
}
class ChildClass extends BaseClass
{
public void Display()
{
System.out.println("This is the method of child class");
}
}
class MainClass
{
public static void main(String args[])
{
ChildClass c = new ChildClass();
c.Display();
}
}
Here I have declared method Display() in the ChildClass class. Is this the way we can override a method. Aren't we using any keyword like override for overriding the method?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes.
ASKER