A class can inherit the properties and behavior of another class.
A class can implement multiple interfaces.
A class uses the keyword implements to implement an interface.
A class uses the keyword extends to inherit a class.
An interface can inherit zero or more interfaces.
An interface cannot inherit a class.
An interface uses the keyword extends to inherit another interface.
Inheriting a class is also known as subclassing.
A class that inherits another class is called a derived class or subclass.
A class that is inherited is called a parent or base class.
Private members of a base class cannot be inherited in the derived class.
A derived class can only inherit members with the default access modifier if both the base class and the derived class are in the same package.
A class can implement multiple interfaces but can inherit only one class.
An abstract class can inherit a concrete class, and a concrete class can inherit an abstract class.
With inheritance, you can refer to an object of a derived class using a variable of a base class or interface.
An object of a base class can't be referred to using a reference variable of its derived class.
When an object is referred via base class reference, the reference variable can only access the variables/members in the base class.
When an object is referred using a reference variable of an interface implemented by a class, the reference variable can access only the variables and methods defined in the interface.
The this reference always points to an object's own instance.
The keyword this can refer to all methods and variables that are accessible to a class.
If a method defines a local variable or method parameter with the same name as an instance variable, the keyword this can be used to access the instance variable.
You can call one constructor from another constructor by using the keyword this.
super can refer to the parent class or the base class of a class.
The super can access a variable or method from the base class.
The reference variable super can refer to the constructors of the base class in a derived class.
In Java, polymorphism means when there's an inheritance relationship between classes, and both the base and derived classes define methods with the same name.
The polymorphic methods are also called overridden methods.
Overridden methods should define methods with the same name, same argument list, same list of method parameters.
The return type of the overriding method can be the same, or a subclass of the return type of the overridden method in the base class, which is also known as covariant return type.
Access modifiers for an overriding method can be the same or less restrictive but can't be more restrictive than the method being overridden.
A derived class overrides a method in the base class if it defines a method with the same name, same parameter list, and same return type as in the derived class.
When implementing polymorphism with classes, a method defined in the base class may or may not be abstract.
When implementing polymorphism with interfaces, a method defined in the base interface is always abstract.