📚 Practice Mode

Core Java (GATE - CS)

Learn at your own pace with hints and detailed explanations

1 / 15
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