Assume you have a superclass Pet and subclasses Cat and Dog. In the following code fragment, the

Question:

  1. 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];

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: