Write a program with a mother class and an inherited daugther class. Both of them should have a
method void display () that prints a message (different for mother and daugther).In the main define a
daughter and call the display() method on it.
package mother;
public class Mother {
public void display(){
System.out.println("This is a mother class class\n");
}
public static void main(String[] args) {
daughter d = new daughter();
d.display();
}
}
class daughter extends Mother{
public void display(){
System.out.println("This is a daughter class\n");
}
}
Comments
Leave a comment