Ask Question
11 May, 06:02

Write a class for a Cat that is a subclass of Pet. In addition to a name and owner, a cat will have a breed and will say "meow" when it speaks. Additionally, a Cat is able to purr (print out "Purring ... " to the console).

+2
Answers (1)
  1. 11 May, 08:38
    0
    The Java class is given below with appropriate tags for better understanding

    Explanation:

    public class Cat extends Pet{

    private String breed;

    public Cat (String name, String owner, String breed) {

    / * implementation not shown * /

    super (name, owner);

    this. breed = breed;

    }

    public String getBreed () {

    return breed;

    }

    public void setBreed (String breed) {

    this. breed = breed;

    }

    public String speak () { / * implementation not shown * /

    return "Purring ...";

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a class for a Cat that is a subclass of Pet. In addition to a name and owner, a cat will have a breed and will say "meow" when it ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers