Examine the following code and select the correct statements (choose all possible options): class Bottle { Bottle() {} Bottle(WaterBottle w) {} } class WaterBottle extends Bottle { WaterBottle() { } WaterBottle(Bottle w) { } }
Examine the following code and select the correct statements (choose all possible
options):
class Bottle {
Bottle() {}
Bottle(WaterBottle w) {}
}
class WaterBottle extends Bottle {
WaterBottle() { }
WaterBottle(Bottle w) { }
}
a) The class Bottle defines two overloaded constructors.
b) The class WaterBottle defines two overloaded constructors.
c) The class compiles successfully—a base class can use reference variables of its
derived class as method parameters.
d) Bottle and WaterBottle cause syntax errors.
e) The class compiles successfully - A derived class can use reference variables of its
base class as method parameters.
f) A base class can’t pass reference variables of its defined class, as
method parameters in constructors.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps