Page 1 of 1

The data type Bird is a generic type for any kind of bird. A Bird cannot be created without it being a more specific typ

Posted: Sat May 14, 2022 3:18 pm
by answerhappygod
The Data Type Bird Is A Generic Type For Any Kind Of Bird A Bird Cannot Be Created Without It Being A More Specific Typ 1
The Data Type Bird Is A Generic Type For Any Kind Of Bird A Bird Cannot Be Created Without It Being A More Specific Typ 1 (340.6 KiB) Viewed 56 times
(f) In the following code, which version
of takeOff() is called: Bird’s, Eagle’s
or Loon’s? Bird b = new Loon();
(g) Is there an error with the following code? If so, then
explain what it is and state whether it is a compile time error or
a runtime error. If not, then explain why not.
The data type Bird is a generic type for any kind of bird. A Bird cannot be created without it being a more specific type of Bird. • A Bird instance can take off for flight by calling its public void takeoff() method. The Bird type does not supply an implementation of this method. • Eagle is a subtype of Bird. Every Eagle instance has its own wingSpan data field (this is a double). • Eagle overrides method takeoff(). • A Lake Animal is a type that represents animals that live at a lake. It contains the method public void swim(). LakeAnimal does not supply an implementation of this method. . Both Bird and LakeAnimal do not have any data fields. • Loon is a subtype of both Bird and LakeAnimal. Loon overrides method takeOff () and method swim(). • The Loon type keeps track of the maximım dive depth among all Loon instances. This is stored in a variable of type double called maxDiveDepth. • Both Eagle and Loon have constructors that take no arguments.