Abstraction
using System;
/* Class having abstract keyword and having, abstract keyword with some of its methods (not all) is known as
an Abstract Base Class.An Abstract Base class can not be instantiated. */
abstract class Human
{
public abstract void see(); // These are abstract methods.
public abstract void hear();
public void walk()
{
Console.WriteLine("Humans can walk");
}
}
//Now we derive a class of 'Student' from the class Human which should implement all abstract methods in the baseclass Human.
class Student : Human
{
public override void see()
{
Console.WriteLine("Humans can see");
}
public override void hear()
{
Console.WriteLine("Humans can hear");
}
static void Main(String[] args)
{
Student c = new Student();
c.see();
c.hear();
c.walk();
Console.ReadLine();
}
}
Output:
Humans can see
Humans can hear
Humans can walk