Inheritance is a mechanism in which a new class is derived from an existing class. The derived class inherits all the members (fields, methods, and nested classes) from the base class.