In the diagram below, class C inherits class B and class B inherits class A. This means class C is the child of class B and class B is the child to class A.
This is an example of multilevel inheritance. We have three classes in this example: student, teacher and principal. Teacher extends to students class and principal extends to teacher class. The principal class is able to use the methods of both student and teacher classes.
Example 1
class students{ //class students is the parent class
Multiply two numbers in Java using scanner| 5 different ways In this article, we will…
5 Different ways to Divide two numbers in Java using scanner In this article, we…
Learn 8 Ways to Subtract Two Numbers Using Methods in Java In this article, we…
10 ways to subtract two numbers in Java In this article, we will discuss the…
Java Code Examples – Multiply Two Numbers in 5 Easy Ways In this article, we…
How to Divide two numbers in Java| 5 different ways In this article, we will…
This website uses cookies.