- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
MultiLevel Inheritance in Dart Programming
Multilevel inheritance in dart is the case when different classes are inheriting in a form of chain, i.e., one class extends some parent class, and the other class extends the class that was extending the parent class.
The syntactical representation of multilevel inheritance looks something like this −
class A {} class B extends A {} class C extends B {}
If we notice the above syntax, we can clearly see that the class A is the parent class for the class B, which is extending it. Also, the class B acts as a parent for class C, which is extending class B.
Multilevel inheritance is nothing but a chaining of inheritance.
Example
Let's consider an example, where we make use of different classes to form a multilevel inheritance in a dart program.
Consider the example shown below −
class Wood{ void printName(){ print("Inside class Wood"); } } class Table extends Wood{ void printTable(){ print("Inside Table class"); } } class TableLegs extends Table{ void printTableLegs(){ print("Inside TableLegs class"); } } void main(){ TableLegs tl = new TableLegs(); tl.printTableLegs(); tl.printTable(); tl.printName(); }
In the above example, we have three different classes, namely Wood, Table, and TableLegs. Inside the main function, we create an object of the TableLegs class and then invoke the methods of the parent class that the class extends.
Output
Inside TableLegs class Inside Table class Inside class Wood
- Related Articles
- Inheritance in Dart Programming
- Hierarchical Inheritance in Dart Programming
- Multilevel inheritance in Java
- C# Example for MultiLevel Inheritance
- Creating a Multilevel Inheritance Hierarchy in Java
- Java Runtime Polymorphism with multilevel inheritance
- Comments in Dart Programming
- Constructors in Dart Programming
- Enumerations in Dart Programming
- Functions in Dart Programming
- Immutability in Dart Programming
- Iterables in Dart Programming
- Lists in Dart Programming
- Loops in Dart Programming
- Maps in Dart Programming
