At Westonci.ca, we provide reliable answers to your questions from a community of experts. Start exploring today! Join our Q&A platform and get accurate answers to all your questions from professionals across multiple disciplines. Discover detailed answers to your questions from a wide network of experts on our comprehensive Q&A platform.

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.

Sagot :

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();

}

}