 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Creating a Multilevel Inheritance Hierarchy in Java
Inheritance involves an object acquiring the properties and behaviour of another object. So basically, using inheritance can extend the functionality of the class by creating a new class that builds on the previous class by inheriting it.
Multilevel inheritance is when a class inherits a class which inherits another class. An example of this is class C inherits class B and class B in turn inherits class A.
A program that demonstrates a multilevel inheritance hierarchy in Java is given as follows:
Example
class A {    void funcA() {       System.out.println("This is class A");    } } class B extends A {    void funcB() {       System.out.println("This is class B");    } } class C extends B {    void funcC() {       System.out.println("This is class C");    } } public class Demo {    public static void main(String args[]) {       C obj = new C();       obj.funcA();       obj.funcB();       obj.funcC();    } }  Output
This is class A This is class B This is class C
Advertisements
 