Given a java source file: What changes will make this code compile? (Select Two)
A.
Removing the private modifier from the two () method
B.
Adding the public modifier to the declaration of class x
C.
Adding the protected modifier to the x() constructor
D.
Changing the private modifier on the declaration of the one() method to protected
E.
Removing the Y () constructor
Part of question missing, check:
http://www.aiotestking.com/oracle/what-changes-will-make-this-code-compile-2/
and answer is D
Answer is A & D
Answer: D
Explanation:
Based on the missing code fragment
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 ();
}
}
A, B, C are wrong because method one() is inaccessible for class Y in all cases.