Question: Question on Inheritance & Polymorphism A) Given this code: Animal myDog = new Dog(Spot); myDog.speak(); What do we know about the Dog class and the
Question on Inheritance & Polymorphism
A) Given this code:
Animal myDog = new Dog(Spot);
myDog.speak();
What do we know about the Dog class and the Animal class?
B) Given a class Animal has a child Cat and a child BigCat. Cat has a child class Tabby and Big Cat has a child class Tiger.
Given:
Animal animal;
Cat kitty = new Cat();
BigCat big = new BigCat();
Tiger tig = new Tiger();
Tabby tab = new Tabby();
Identify each line of code that will cause an error:
|
| Error yes/no | Why? |
| animal = big; |
|
|
| kitty = null; |
|
|
| tab = tig; |
|
|
| big = tig; |
|
|
| big = tab; |
|
|
| tig = kitty; |
|
|
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
