Inheritance in Java Inheritance is one of the feature of Object-Oriented Programming (OOPs). Inheritance allows a class to use the properties and methods of another class. In other words, the derived class inherits the states and behaviors from the base class. The derived class is also called subclass and the base class is also known as super-class . The derived class can add its own additional variables and methods. These additional variable and methods differentiates the derived class from the base class. Inheritance is a compile-time mechanism. A super-class can have any number of subclasses . But a subclass can have only one superclass. This is because Java does not support multiple inheritance. The superclass and subclass have “is-a” relationship between them. Let’s have a look at the example below. Inheritance Example Let’s consider a superclass Vehicle . Different vehicles have different features and properties howeve...
IF YOU CAN DREAM IT. YOU CAN ACHIEVE IT.

Comments
Post a Comment