Which of the following statements are true?
1.To be overridden a method must have the same name, parameter types and return type
2.It is possible to override methods in a superclass or the same class
3.classes that are marked as final may not be extended. - true
4.an overriding method cannot have more access (be more public) than the method being overriden.
Anvi,
1. The overridden method must have the same name, parameter types. It can have the same return type or covarient types.
2. Its not possible to override methos in the same class
3. ....
4. class X{
String aMethod(){System.out.println("In Super class");}
}
class Y extends X{
private String aMethod(){System.out.println("In Super class");} //gives error as the access is restricted
}
Thanks