Abstract
classes are Classes which cannot be instantiated. This means one cannot make a
object of this class or in other way cannot create object by saying ClassAbs
abs = new ClassAbs(); where ClassAbs is abstract class.Abstarct classes
contains have one or more abstarct methods, ie method body only no
implementation.
abstract
class human
{
//Abstract methods
public
abstract void hair();
//Concrete method
public void display()
{
System.Console.WriteLine("hello");
}
}
class boys :
human
{
public override void hair()
{
System.Console.WriteLine("Small");
}
}
class girls
: human
{
public override void hair()
{
System.Console.WriteLine("LONG");
}
}
class a
{
public static void Main()
{
boys b=new boys();
girls g=new girls();
b.hair();
g.hair();
b.display();
g.display();
}
}
No comments:
Post a Comment