Program
using System;
namespace Polymorphism
{
class MethodOverriding2
{
abstract class Shape
{
public abstract int area();
}
class Rectangle : Shape
{
private int length,
width;
public Rectangle(int a = 0, int b = 0)
{
length = a;
width = b;
}
public override int area()
{
return (width * length);
}
}
static void Main(string[] args)
{
Rectangle r = new Rectangle(10, 7);
double a = r.area();
Console.WriteLine("Area of Rectangle is: {0}", a);
Console.ReadKey();
}
}
}
Output
Area of Rectangle is: 70
No comments:
Post a Comment