What does overriding a method mean?
- deleting the parent method for all classes
- writing a new version in the subclass used for its objects
- copying the method into every object
Class Bus extends class Vehicle and adds seats. What does a Bus object automatically have?
- the Vehicle fields and methods plus seats
- only the seats
- nothing until rewritten
If Bus does not override refuel, a Bus object calling refuel runs the Vehicle version.
Circle one: True False
An override of trip_info must reuse the parent text then add seats. What belongs inside it?
- a call to super() plus the new seats line
- a copy of the whole Vehicle class
- a second class named Bus
Bus overrides trip_info but inherits refuel. A Bus object calls both. Which versions run?
- Vehicle trip_info and Vehicle refuel
- Bus trip_info and Bus refuel
- Bus trip_info and Vehicle refuel
A programmer writes class Bus(Vehicle) with seats = 40 and a new trip_info. Which demand does this meet?
- adds one field and overrides one method
- adds one method and overrides one field
- removes the parent entirely
A programmer makes Penguin a subclass of Bird to reuse fly(), then overrides fly() to do nothing. What is the better call?
- keep it, since overriding fixes everything
- restructure so Penguin never promises flight it cannot do
- delete fly() from every bird
Car and Bus share Vehicle, but someone proposes adding Airplane under Vehicle to reuse trip_info. What is the flaw?
- an airplane also travels, so nothing is wrong
- subclasses may never add new fields
- Vehicle promises road behaviour its other children share, which an airplane breaks