Wednesday 2 November 2011

Super keyword in Java| Java tutorials


Super keyword in Java
Super keyword is mainly used to access superclass variables and methods in subclass.

The variables and method s of a superclass can be overridden by the subclass. In case of overriding , a subclass object calls its own variables or methods. That is,subclass cannot access superclass methods as long as they are overridden. Other way, the overridden variable or method blocks that of super class.

Java still provides a way to access the superclass members,even if they are overridden. It is possible by using super keyword.

Note:The restriction of using super keyword is that we should not use it from a static method.

No comments:

Post a Comment