Question: Adopt a PetGiven the provided main ( ) method , create two ( 2 ) staticclasses inside of the HouseholdPets class. ( 1 ) Create
Adopt a PetGiven the provided mainmethod create two staticclasses inside of the HouseholdPets class. Create HouseholdPetclass
Declare a String field called name do notassign 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 describethat prints out the following string:This pet's name is this.name Create DogPet class that extendsHouseholdPet
Declare a String field called sound
Create a public constructor that takes in a String, and sets the field here. Use the superkeyword to inherit the field name from HouseholdPet, like so: supername;
Create a public void method for DogPetcalled describe that prints the following:Systemout.printlnThis dog's name is this.name and they this.sound ;
import java.io;
import java.util.;
import java.text.;
import java.math.;
import java.util.regex.;
public class HouseholdPets
public static void mainString args
Scanner in new ScannerSystemin:
String name innextLine;
HouseholdPet pet new HouseholdPetname;
String name innextLine;
String sound innextLine;
DogPet dog new DogPetname "sound;
pet.describe;
dog.describe;
end of main
DO NOT CHANGE THE CODE ABOVE THIS LINE
WRITE YOUR CODE HERE
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
