Given:
public class Speak { /* Line 1 */
public static void main(String[] args) { /* Line 2 */
Speak speakIT = new Tell(); /* Line 3 */
Tell tellIt = new Tell(); /* Line 4 */
speakIT.tellItLikeItIs(); /* Line 5 */
(Truth)speakIt.tellItLikeItIs(); /* Line 6 */
((Truth)speakIt).tellItLikeItIs(); /* Line 7 */
tellIt.tellItLikeItIs(); /* Line 8 */
(Truth)tellIt.tellItLikeItIs(); /* Line 9 */
((Truth)tellIt).tellItLikeItIs(); /* Line 10 */
}
}
class Tell extends Speak implements Truth {
public void tellItLikeItIs() {
System.out.println("Right on!");
}
}
interface Truth { public void tellItLikeItIs()};
Which three lines will compile and output “right on!”?
A.
Line 5
B.
Line 6
C.
Line 7
D.
Line 8
E.
Line 9
F.
Line 10
C, D and F is correct. Line 5 will not compile
C,D and F are correct.
why does line 5 not compile?
I agree C D F are the correct answers
Line 5 will give you an method is undefined for type error.
Line 6 and 9 have the wrong syntax, should be ( (class) var ).method( )
78-10
cdf