Abstarct function and abstract class

Posted by Ersudeep13 under Cloud on 4/28/2016 | Points: 10 | Views : 152 | Status : [Member] | Replies : 1
Abstract Methods--> A method without Method Body is known as abstract method. it contains only declaration of the method. If we want to define a abstract method we need to use abstract modifier on that method.

Abstract Function--> A function which contains only Declaration/signature and doesn't contain Implementation/Body/Definition is known as Abstract function. To make any function as abstract use abstract keyword. An abstract function should be terminated. overridding of an abstract function is compulsory.

Abstract Class--> A class which contains one or more abstract function is known as an abstract class.To make any Class as abstract use abstract keyword. It's Compulsory to create/ derive a new class from an abstract class in order to provide functionality to its abstract functions.
An abstract class can contain Non-abstarct functions. An abstract class can contain all member of a class. By default abstract class functions are not treated as public and abstract.

Program for abstract class---------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Abstract
abstract class Employee
protected int EmpId, EAge;
protected string EName, EAddress;
public abstract void GetEmpData();
public virtual void DisplayEmpData()
Console.Write("Enter Employee Details");
this.EmpId = Convert.ToInt32(Console.ReadLine());
this.EName = Console.ReadLine();
this.EAddress = Console.ReadLine();
this.EAge = Convert.ToInt32(Console.ReadLine());
public virtual void DispalyEmpData()
Console.WriteLine("Employee Id is :-" + this.EmpId);
Console.WriteLine("Employee Name is :-" + this.EName);
Console.WriteLine("Employee Address is :-" + this.EAddress);
Console.WriteLine("Employee Age is :-" + this.EAge);
class Manager : Employee
double Bonus, CA;
public override void GetEmpData()
Console.Write("Enter Managers Details :-");
EmpId = Convert.ToInt32(Console.ReadLine());
EName = Console.ReadLine();
Bonus = Convert.ToDouble(Console.ReadLine());
CA = Convert.ToDouble(Console.ReadLine());
public override void DispalyEmpData()
Console.WriteLine("Manager Id is" + EmpId);
Console.WriteLine("Manager Name is" + EName);
Console.WriteLine("Manager Bonus is" + Bonus);
Console.WriteLine("Manager CA is" + CA);
class Abstract
static void Main(string[] args)
Manager Obj1 = new Manager();

output for this program is----

Enter manager Detail is-- 10
Manager Id is:- 10
Manager Name is:- ravi
Manager Bonus is:- 15000
Manager CA is:- 25000


Posted by: Rajnilari2015 on: 4/28/2016 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 25

Please post in Interview Section

Thanks & Regards,
RNA Team

Ersudeep13, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response