internal class Program
{
private static void Main(string[] args)
{
DerivedClass1 objDerivedClass1 = new DerivedClass1();
BaseClass objBaseClass = new DerivedClass1();
//DerivedClass1 deri = new BaseClass(); Not allowed
//Not Allowed
objDerivedClass1.abstractProcessSalary();
//Op :-In DerivedClass1- abstractProcessSalary
objBaseClass.abstractProcessSalary();
//Op :- In DerivedClass1- abstractProcessSalary
objDerivedClass1.plainProcessSalary();
//Op :- In DerivedClass1-virtualProcessSalary
objDerivedClass1.virtualProcessSalary();
//Op :- In DerivedClass1-virtualProcessSalary
objBaseClass.virtualProcessSalary();
//Op :- In DerivedClass1-virtualProcessSalary
objBaseClass.plainProcessSalary();
//Op :- In BaseClass- plainProcessSalary
// DerivedClass2 objDerivedClass2 = objDerivedClass1; Not Allowed
//Not Allowed
BaseClass objBaseClass2 = new DerivedClass2();
//Op :- DerivedClass2 objDerivedClass2 = objBaseClass2; Not Allowed
//DerivedClass1 objDerivedClass1 = objBaseClass;
//Not Allowed
Console.Read();
}
}
internal abstract class BaseClass
{
public abstract void abstractProcessSalary();
public virtual void virtualProcessSalary()
{
Console.WriteLine(" In BaseClass- virtualProcessSalary");
}
public void plainProcessSalary()
{
Console.WriteLine(" In BaseClass- plainProcessSalary");
}
}
internal class DerivedClass1 : BaseClass
{
public override void abstractProcessSalary()
{
Console.WriteLine(" In DerivedClass1- abstractProcessSalary");
}
public override void virtualProcessSalary()
{
Console.WriteLine(" In DerivedClass1-virtualProcessSalary");
}
public void plainProcessSalary()
{
Console.WriteLine(" In DerivedClass1- plainProcessSalary");
}
}
internal class DerivedClass2 : BaseClass
{
public override void abstractProcessSalary()
{
Console.WriteLine(" In DerivedClass2-abstractProcessSalary");
}
public override void virtualProcessSalary()
{
Console.WriteLine(" In DerivedClass2-virtualProcessSalary");
}
public void plainProcessSalary()
{
Console.WriteLine(" In DerivedClass2- plainProcessSalary");
}
}
{
private static void Main(string[] args)
{
DerivedClass1 objDerivedClass1 = new DerivedClass1();
BaseClass objBaseClass = new DerivedClass1();
//DerivedClass1 deri = new BaseClass(); Not allowed
//Not Allowed
objDerivedClass1.abstractProcessSalary();
//Op :-In DerivedClass1- abstractProcessSalary
objBaseClass.abstractProcessSalary();
//Op :- In DerivedClass1- abstractProcessSalary
objDerivedClass1.plainProcessSalary();
//Op :- In DerivedClass1-virtualProcessSalary
objDerivedClass1.virtualProcessSalary();
//Op :- In DerivedClass1-virtualProcessSalary
objBaseClass.virtualProcessSalary();
//Op :- In DerivedClass1-virtualProcessSalary
objBaseClass.plainProcessSalary();
//Op :- In BaseClass- plainProcessSalary
// DerivedClass2 objDerivedClass2 = objDerivedClass1; Not Allowed
//Not Allowed
BaseClass objBaseClass2 = new DerivedClass2();
//Op :- DerivedClass2 objDerivedClass2 = objBaseClass2; Not Allowed
//DerivedClass1 objDerivedClass1 = objBaseClass;
//Not Allowed
Console.Read();
}
}
internal abstract class BaseClass
{
public abstract void abstractProcessSalary();
public virtual void virtualProcessSalary()
{
Console.WriteLine(" In BaseClass- virtualProcessSalary");
}
public void plainProcessSalary()
{
Console.WriteLine(" In BaseClass- plainProcessSalary");
}
}
internal class DerivedClass1 : BaseClass
{
public override void abstractProcessSalary()
{
Console.WriteLine(" In DerivedClass1- abstractProcessSalary");
}
public override void virtualProcessSalary()
{
Console.WriteLine(" In DerivedClass1-virtualProcessSalary");
}
public void plainProcessSalary()
{
Console.WriteLine(" In DerivedClass1- plainProcessSalary");
}
}
internal class DerivedClass2 : BaseClass
{
public override void abstractProcessSalary()
{
Console.WriteLine(" In DerivedClass2-abstractProcessSalary");
}
public override void virtualProcessSalary()
{
Console.WriteLine(" In DerivedClass2-virtualProcessSalary");
}
public void plainProcessSalary()
{
Console.WriteLine(" In DerivedClass2- plainProcessSalary");
}
}
No comments:
Post a Comment