Monitor Monitor Teach Monitor Learn
Users Online
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
Forum Threads
Latest Articles
Articles Hierarchy
C# Program to Demonstrate Hierarchical Inheritance
C# Program to Demonstrate Hierarchical Inheritance
This is a C# Program to illustrate hierarchical inheritance.
This C# Program Illustrates Hierarchical Inheritance.
Here Single parent and multiple child and when more than one derived class are created from single base class is called C# Hierarchical Inheritance.
Here is source code of the C# Program to Illustrate Hierarchical Inheritance. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
/* * C# Program to Illustrate Hierarchical Inheritance */ using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Inheritance { class Program { static void Main(string[] args) { Principal g = new Principal(); g.Monitor(); Teacher d = new Teacher(); d.Monitor(); d.Teach(); Student s = new Student(); s.Monitor(); s.Learn(); Console.ReadKey(); } class Principal { public void Monitor() { Console.WriteLine("Monitor"); } } class Teacher : Principal { public void Teach() { Console.WriteLine("Teach"); } } class Student : Principal { public void Learn() { Console.WriteLine("Learn"); } } } }
This C# program is used to illustrate hierarchical inheritance. We have created two classes Principal and Teacher. Using the object variable ‘g’ of Principal class perform the Monitor() procedure. Using the object variable ‘d’ of Teacher class perform the Monitor() and Teach() procedure.
Finally using ‘s’ object variable perform the Monitor() and Learn() procedure. Here Single parent and multiple child and when more than one derived class are created from single base class are called C# Hierarchical Inheritance.