Question: Assume you have a superclass Pet and subclasses Cat and Dog. In the following code fragment, the second and third lines generate compilation errors. Provide
- Assume you have a superclass Pet and subclasses Cat and Dog. In the following code fragment, the second and third lines generate compilation errors. Provide corrected versions of those two lines. Preserve the spirit of the original code. For example, the bottom line should still assign the second pets element into the barky variable.
![Pet[] pets Cat tiger Dog barky = = = [new Cat (), new Dog()}; pets[0]; pets[1];](https://dsd5zvtm8ll6.cloudfront.net/images/question_images/1704/8/7/7/326659e5d0e9e2d71704877325501.jpg)
Pet[] pets Cat tiger Dog barky = = = [new Cat (), new Dog()}; pets[0]; pets[1];
Step by Step Solution
3.44 Rating (157 Votes )
There are 3 Steps involved in it
The issue with the second and third lines of the provided code fragment is that they are attempting ... View full answer
Get step-by-step solutions from verified subject matter experts
