class x {
x() {
}
private void one() {
}
}
public class Y extends x {
Y() {
}
private void two() {
one();
}
public static void main(String[] args) {
new Y().two();
}
}
What changes will make this code compile?
A.
adding the public modifier to the declaration ofclass x
adding the public modifier to the declaration ofclass x
B.
addingthe protected modifier to the x() constructor
addingthe protected modifier to the x() constructor
C.
changingthe private modifier on the declaration of the one() method to protected
changingthe private modifier on the declaration of the one() method to protected
D.
removing the Y() constructor
removing the Y() constructor
E.
removing the private modifier from the two () method
removing the private modifier from the two () method
Risposta C. Infatti con il modificatore privato il metodo non è visibile dentro two.
Nessun commento:
Posta un commento