10.11 LAB: Pet information (derived classes) The base class Pet has private data members petName, and petAge. The derived class Dog extends the Pet class and includes a private data member 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() function.

Respuesta :

Answer:

Answered below.

Explanation:

//Program in Java

Class Test{

public static void main (String[] args){

//create a pet object

Pet pet = new Pet();

//call pet object's printInfo method

pet.printInfo();

//create a new Dog object

Dog dog = new Dog();

//dog can access the printInfo method of the Pet class because it derives from it

dog.printInfo();

//dog can also call it's private method.

dog.getBreed();

}

}