Hi,
1. public class X {
2. public X aMethod() { return this;}
3. }
1. public class Y extends X {
2.
3. }
Which two methods can be added to the definition of class Y? (Choose two)
A. public void aMethod() {}
B. private void aMethod() {}
C. public void aMethod(String s) {}
D. private Y aMethod() { return null; }
E. public X aMethod() { return new Y(); }
Ans - C,E
A.overriden X.aMethod
The return type is incompatable with X.aMethod().
B.The return type is incompatable with X.aMethod().
C.aMethod is not overriden.
D.The return type is incompatable with X.aMethod().
E.Overriden X.aMethod.The return type is compatable with X.aMethod().
Regards,
D.Sitaramayya.