Overriding in java


 

Overriding in java

Click on following link to know all about Overriding in Java

Click on following link to know all about Overriding in Java

Some key points about overriding in java

  1. The overriding method must have same arguments, it means return type of argument should be same with number of argument.
  2. The overriding method must have less restrictive access modifier.
  3. The return type of overriding method must be the same.
  4. If you want your method not to be overridden mark it with final at the beginning.
  5. With context of constructor it can be overloaded but cannot be overridden.
  6. The concrete class overrides the abstract method.
  7. The private method is not overridden.
  8. A default method may be overridden by a default, protected or public method.
  9. A public overridden method then the overriding method must also be in public. But in the case of protected it can be overridden by protected and public also.
  10. A protected method may not be overridden by a default or private method.

More about Overriding

Ads