Coder Social home page Coder Social logo

shyamkumar-ai-ds / 19ai308-object-oriented-programming-using-csharp--exp-8-name-hiding-with-interface-inheritance Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aswini-j/19ai308-object-oriented-programming-using-csharp--exp-8-name-hiding-with-interface-inheritance

0.0 0.0 0.0 5 KB

C# 100.00%

19ai308-object-oriented-programming-using-csharp--exp-8-name-hiding-with-interface-inheritance's Introduction

19AI308-Object-Oriented-Programming-using-CSharp--Exp-8-Name-Hiding-with-interface-inheritance

AIM:

To implement name hiding with interface inheritance. Aim is to create an interface IMario with a method Ability(). Implement this interface in a class Mario and override the Ability() method also to create another class SuperMario that inherits from Mario and hides the Ability() method using the new keyword.

ALGORITHM:

Step 1:

Create interface IMario with method Ability for Mario classes.

Step 2:

Mario class implements IMario, defines virtual Ability method.

Step 3:

SuperMario extends Mario, overrides Ability method with new.

Step 4:

Instantiate SuperMario and Mario, call Ability on each.

Step 5:

SuperMario's Ability prints "This is inside SuperMario", Mario's prints "This is inside Mario".

PROGRAM:

#### Name : Shyam Kumar A
#### Reg No: 212221230098
using System;
public interface IMario
{
    void Ability();

}
class Mario:IMario{
    public virtual void Ability()
    {
        Console.WriteLine("Mario's Ability:Normal Dancing");
    }
}  
class SuperMario:Mario
{
    public new void Ability()
    {
        Console.WriteLine("Mario's Ability:Super Dancing");
    }
}
class Program
{
    static void Main(string[]args)
    {
        IMario mario=new Mario();
        SuperMario superMario=new SuperMario();
        mario.Ability();
        superMario.Ability();

    }
}

OUTPUT:

image

RESULT:

Thus, the program has been executed successfully.

19ai308-object-oriented-programming-using-csharp--exp-8-name-hiding-with-interface-inheritance's People

Contributors

aswini-j avatar shyamkumar-ai-ds avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.