Card 28 / 37: class Type { public Object getTypeName(){ return "Type"; } } class SubType extends Type { public String getTypeName(){//line 8 return "SubType"; } } public class Tester { public static void main(String[] args) { Type first = new SubType(); //line 16 System.out.println(first.getTypeName()); //line 17 } } What modification is necessary to produce the following output : SubType
A)
At line 8 change ´the return type from String to Object to be a correct
B)
overloading of getTypeName()
C)
No modification is needed
D)
At line 16 change Type to SubType
E)
At line 17 cast first.getTypeName() to String
Answer:
C) No modification is needed
Previous Card | ← Previous Card Button |
Next Card | → Next Card Button |
Flip Card | Space-Bar |
|