A)
->redefining the functionality of super class method in sub class is known as method overriding.
->in the implementation of method overriding super class method is known as “overridden method” and sub class method is known as “overriding method”.
->to implement the method overriding the fallowing rules must be fallowed.
1) Method signature must be same. i.e. overriding and overridden method should have same name and same parameter list.
2) Method return type should be the same.
3) Overriding method (child class method) should not have weaker access privilege that that of overriding method (parent class method).
4) Overriding method should not have more checked exceptions in the exception specification than that of overridden method. But overriding method may contain more unchecked exceptions.
Comments
Post a Comment