Adarsh Achar

Adarsh Achar

  • NA
  • 4
  • 713

Difference between method hiding and method overriding

May 21 2016 6:07 AM
using System;
namespace MethodOverridre
{
class VTU
{
public virtual void Admission()
{
Console.WriteLine("This is VTU Admission");
}
public virtual void Rules()
{
Console.WriteLine("This is VTU Rules");
}
public virtual void Certificate()
{
Console.WriteLine("This is VTU Certificate");
}
public virtual void Exam()
{
Console.WriteLine("This is VTU Exam");
}
public virtual void Marks()
{
Console.WriteLine("This is VTU Marks");
}
}
class Autonomous : VTU
{
public override void Exam()
{
Console.WriteLine("This is Autonomous Exam");
}
public override void Marks()
{
Console.WriteLine("This is Autonomous Marks");
}
}
class Program
{
static void Main(string[] args)
{
VTU vt = new Autonomous();
vt.Admission();
vt.Rules();
vt.Certificate();
vt.Marks();
Console.ReadKey();
}
}
}
In the above code is there any specific reason to get reference of base class while creating a child class object? Any how child class will inherits all the methods of base class.

Answers (1)