Given:
class One {
void foo() { }
}
class Two extends One {
14. // insert method here
}
Which three methods, inserted individually at line 14, will correctly complete class Two? (Choose three.)
A.
int foo() { /* more code here */ }
B.
void foo() { /* more code here */ }
C.
public void foo() { /* more code here */ }
D.
private void foo() { /* more code here */ }
E.
protected void foo() { /* more code here */ }
Explanation:
A:
Main.java:14: foo() in Two cannot override foo() in One; attempting to use incompatible return type
found : int
required: void
int foo() { /* more code here */ }
^
1 errorB:
compiled successfullyC:
compiled successfullyD:
Main.java:14: foo() in Two cannot override foo() in One; attempting to assign weaker access privileges; was package
private void foo() { /* more code here */ }
^
1 errorE:
compiled successfully