Question: In Java: Class Pet has name, age, weight and breed as attributes. Give your class a default and another constructor that initializes all attributes. Add
In Java:
Class Pet has name, age, weight and breed as attributes.
Give your class a default and another constructor that initializes all attributes.
Add the necessary set and get methods in addition to a toString method.
Create a new class called Dog that is derived from the Pet class.
The new class Dog has the additional attribute boosterShot (type boolean), which is true if the pet has had its booster shot and false if not.
Give your classes a reasonable complement of constructors and accessor methods.
Write a driver program to test all your methods, you should also read five pets of type Dog and displays the name and breed of all dogs that are over two years old and have not had their booster shots.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
