Inheritance Keywords
Inheritance can use the two keywords extends and implements to implement inheritance, and all classes inherit from Java.lang.Object, and when a class does not inherit two keywords, the default inherits Object (this class is in the Java.lang in the package, so no importis required) ancestor classes.
Extends keywords
In Java, the inheritance of a class is a single inheritance, that is, a subclass can only have one parent class, so extends can inherit only one class.
Public Class Animal { "
< Span class= "Hl-code" >< Span class= "hl-comment" > public class Span class= "Hl-identifier" >penguin extends animal{ }
Implements keywords
The use of the Implements keyword can be disguised to make Java has multiple inheritance, using the scope of the class to inherit the interface, you can inherit multiple interfaces (interfaces and interfaces separated by commas).
Public Interface A { }
< Span class= "hl-brackets" > public interface b { "
< Span class= "hl-reserved" > public class c implements Ab { "
Super and this keyword
Super Keyword: We can use the Super keyword to implement access to a parent class member to refer to the parent class of the current object.
This keyword: point to your own reference.
Final keyword
The final keyword declares that a class can be defined as a class that cannot be inherited, that is, a final class, or for a decorated method that cannot be overridden by a quilt class, that an instance variable can be defined as final, and that a variable defined as final cannot be modified. A method declared as a final class is automatically declared final, but the instance variable is not final
Constructors
A subclass cannot inherit the constructor (constructor or constructor) of the parent class, but the constructor of the parent class has parameters, and the constructor of the parent class must be explicitly called through the Super keyword in the constructor of the child class with the appropriate argument list. If the parent class has a parameterless constructor, it is not necessary to call the parent class constructor with super in the constructor of the subclass, and if the Super keyword is not used, the system automatically calls the parent class's parameterless constructor
Keywords in Java