An Abstract class is a class with incomplete functionality.
It shall or shall not have abstract methods. As in the case with Interface you can't create an object of Abstract class.
It shall or shall not have abstract methods. As in the case with Interface you can't create an object of Abstract class.
abstract class Person
{
public abstract void Print();
public void Blog()
{
Console.WriteLine("ShalvinPD.blogspot.com");
}
}
class Shalvin : Person
{
public override void Print()
{
Console.WriteLine("Shalvin P D");
}
}
class Program
{
static void Main(string[] args)
{
//Error cannot create an object of Abstract Class
//Person p = new Person();
Shalvin s = new Shalvin();
s.Print();
s.Blog();
Console.ReadLine();
}
}
Here I am having an Abstract class called person with an abstract method called Print and an ordinary method called blog. In the sub class I am overriding the abstract Print method.

No comments:
Post a Comment