Introducing Java Inheritance Concepts
Inheritance
Java Inheritance (Subclass and Superclass)
In Java, it is possible to inherit attributes and methods from one class to another. We group the "inheritance concept" into two categories.
- subclass (child) - the class that inherits from another class
- superclass (parent) - the class being inherited from
class BMWCar() {
tires;
engine;
lights;
doors;
break liner;
seat;
steering wheel;
drive() {}
reverse() {}
break() {}
signal light() {}
horns() {}
}
class BMWModernCar() {
}
Taking the things of one class to another class is called Inheritance. It needs to create a relationship between the two classes. Then the first class is called "Super Class" and the new class is called "Sub Class".
GitHub Projects
Comments
Post a Comment