Multiple choice

What changes will make the above code compile?

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 ();
}
}

  1. Removing the private modifier from the two () method

  2. Adding the public modifier to the declaration of class X

  3. Changing the private modifier on the declaration of the one() method to protect

  4. Removing the Y () constructor

  5. None of these

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

This change will also not allow the code to compile because there is no error in that constructor.