//run time polymorphism
class parent{
public void display(){
System.out.println("this is a parent class");
}
}
class child extends parent{
public void display(){
System.out.println("this is a child class");
}
}
public class Main{
public static void main(String[] args){
parent obj=new parent();
obj.display();
// now we want to see display() of child class too...
parent obj1=new child();
obj1.display();
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: