Users Online

· Guests Online: 126

· Members Online: 0

· Total Members: 188
· Newest Member: meenachowdary055

Forum Threads

Newest Threads
No Threads created
Hottest Threads
No Threads created

Latest Articles

C# Program to Demonstrate Multilevel Inheritance

C# Program to Demonstrate Multilevel Inheritance

 

 

This is a C# Program to demonstrate multilevel inheritance.

Problem Description

This C# Program Demonstrates Multilevel Inheritance.

Problem Solution

Here when a derived class is created from another derived class, then that inheritance is called as multi level inheritance.

Program/Source Code

Here is source code of the C# Program to Demonstrate Multilevel Inheritance. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.

/*
 * C# Program to Demonstrate Multilevel Inheritance
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Inherit
{
    class inheri : vehicle
    {
        public void Noise()
        {
            Console.WriteLine("All Vehicles Creates Noise !! ");
        }
        static void Main(string[] args)
        {
           inheri obj = new inheri();
            obj.mode();
            obj.feature();
            obj.Noise();
            Console.Read();
        }
    }
    class Mode
    {
        public void mode()
        {
            Console.WriteLine("There are Many Modes of Transport !!");
        }
    }
    class vehicle : Mode
    {
        public void feature()
        {
            Console.WriteLine("They Mainly Help in Travelling !!");
        }
    }
}
Program Explanation

This C# program is used to demonstrate multilevel inheritance. Here when a derived class is created from another derived class, then that inheritance is called as multi-level inheritance. We have created a inherit namespace.

 

Create a class inheri() procedure that inherit the vehicle class. Create the variable ‘obj’ as an object for inheri() procedure . Using the ‘obj’ object variable we are calling the mode(), feature(), Noise() function.

Runtime Test Cases
 
There are Many Modes of Transport !!
They Mainly Help in Travelling !!
All Vehicles Creates Noise !!

 

Comments

No Comments have been Posted.

Post Comment

Please Login to Post a Comment.

Ratings

Rating is available to Members only.

Please login or register to vote.

No Ratings have been Posted.
Render time: 1.10 seconds
10,831,263 unique visits