super
keyword in java
The super keyword
in java is a reference variable which is used to refer immediate parent class
object.
Whenever you create the
instance of subclass, an instance of parent class is created implicitly which
is referred by super reference variable.
Usage of java super
Keyword
- super can be used to refer
immediate parent class instance variable.
- super can be used to invoke
immediate parent class method.
- super() can be used to invoke
immediate parent class constructor.
The final keyword in java is used to restrict the user. The java final keyword can be used in many context. Final can be:
- variable
- method
- class
Java final variable
Java final method
If you make any method as final, you cannot override it.
3) Java final class
If you make any class as final, you cannot extend it.
Is final method inherited?
Ans) Yes, final method is inherited but you cannot override it.
Can we declare a constructor final?
No, because constructor is never inherited.
No comments:
Post a Comment