Q:

Interface concept using C# Language

0

This Program is used to demonstrate the Interface concept

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;

interface shape

  {

    void area();

  }

public class square : shape

  {

    public int i;

    public void area()

      {      

         Console.Write("\nEnter the Side : ");

         i = int.Parse(Console.ReadLine());

         Console.WriteLine("\nArea of Square is : {0}",(i*i));

      }

  }

public class circle : shape

  {

    public double i;

    public void area()

      {      

         Console.Write("\n\nEnter the Radius : ");

         i = double.Parse(Console.ReadLine());

         Console.WriteLine("\nArea of Circle is : {0}",(3.14*i*i));

      }

  }



public class exam

  {

     public static void Main()

       {

           shape s;

           square k  = new square();

           circle c = new circle();

           s=k;

           k.area();

           s=c;

           c.area();                       

       }

 } 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now