What changes will make this code compile?

Given a java source file: What changes will make this code compile? (Select Two)

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



Leave a Reply 3

Your email address will not be published. Required fields are marked *


mwin

mwin

Answer is A & D

imyrta

imyrta

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.