Inheritance and Polymorphism Flashcards
class reusability has two forms …. and ….
composition and inheritance
composition is called a ….
has- a
has - a or composition means
placing a reference / object of a class in another class
inheritance is (is-a)
extending a class with another class
inheritance means
that a new class inherits from an existing class, it inherits all its members and characteristics
subclass constructor has to call… directly or indirectly
base/parent class
base/ parent class is called using
super()
super can be the last statement in the constructor of subclass (yes / no)
no, it must be the first statement in the subclass
why does super class constructor must be called
to make sure all class members are initialized
access modifier for an overriding method has to be the same ?
no it can be more but not less ( more access is given )
if an access modifier protected then the child class can be ?
public or none
any method defined in java is overridable by default unless it is ….
final
method of subclass has the same signature of super class?
true
method signture is
same name, same parameters and return type
overloading is between methods
between methods of the same class
same method name but different number of parameters or parameter type but not return type is considered overloading
true
a class can have how many parent classes?
exactly one
abstracted can not be …. or…..
inherited or instantiated