Answer to Question #239195 in Java | JSP | JSF for zakia kafeel

Question #239195

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.


1
Expert's answer
2021-09-19T08:05:48-0400


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");
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS