Question: Given the provided main ( ) method, create two ( 2 ) static classes inside of the HouseholdPets class. ( 1 ) Create HouseholdPetclass Declare
Given the provided main method, create two static classes inside of the HouseholdPets class.
Create HouseholdPetclass
Declare a String field called name do not assign it a value and do not make it private
Create a public constructor that takes in a String, and sets the field here.
Create a public method called describe that prints out the following string:
"This pet's name is
this.name
Create DogPet class that extends HouseholdPet
Declare a String field called sound
Create a public constructor that takes in a String, and sets the field here. Use the super keyword to inherit the field name from HouseholdPet, like so: supername;
Create a public void method for DogPet called describe that prints the following:
System.out.printlnThis dog's name is
this.name amd they this. sound ; In java
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
