190k views
4 votes
The base class Pet has private fields petName, and petAge. The derived class Dog extends the Pet class and includes a private field for dogBreed. Complete main() to: create a generic pet and print information using printInfo(). create a Dog pet, use printInfo() to print information, and add a statement to print the dog's breed using the getBreed() method.

1 Answer

3 votes

Answer:

Hello attached is the Java program written to solve the problem

The Pet.java and Dog.java files are unaltered

Step-by-step explanation:

The input and output codes are attached as well i.e the second image is the input while the third image is the output code

The base class Pet has private fields petName, and petAge. The derived class Dog extends-example-1
The base class Pet has private fields petName, and petAge. The derived class Dog extends-example-2
The base class Pet has private fields petName, and petAge. The derived class Dog extends-example-3
User Maikel Bollemeijer
by
6.1k points