Given:
abstract class Boat {
String doFloat() { return “floating”; }
abstract void doDock();
}
class Sailboat extends Boat {
public static void main(String[] args) {
Boat b = new Sailboat(); // Line A
Boat b2 = new Boat(); // Line B
}
String doFloat() { return “slow float”; } // Line C
void doDock() { } // Line D
}
Which two are true about the lines labeled A through D?
A.
The code compiles and runs as is.
B.
If only line A is removed, the code will compile and run.
C.
If only line B is removed, the code will compile and run.
D.
If only line D is removed, the code will compile and run.
E.
Line C is optional to allow the code to compile and run.
F.
Line C is mandatory to allow the code to compile andrun.
Explanation:
A: The code will compile. The abstract method doDock() is implemented fine, and doFloat() is overridden.
E: Line C overrides the implementation of doFloat(). This is optional.
Boat b2 = new Boat(); // Line B.. does not confuse anyone?
Chuck Norris can instantiate an abstract class.
cannot be instantiated. It contains abstract method: abstract void doDock();
The correct answers are B and E
Please do not confuse people …
Correct answers are C and E
Correct answers are C and E.
DONT confuse the people with your superficial knowledge
Correct answers are C and E.
Correct answers are C and E.
do not create instance Abstract class => C wrong!
mandatory Override abstract method inside class that extends from abstract class => F
😀 my email : [email protected]
C and E
C E
C E
Please Compile
before reply!
Just poetry 😉
Amen
ce