What will be the result of code execution?

class Class1
{
  public bool Test()
  {
    return true;
  }
}

class Class2
{
  public virtual bool Test()
  {
    return true;
  }
}

class Class3: Class1
{
  public bool Test()
  {
    return false;
  }
}

class Class4: Class2
{
  public bool Test()
  {
    return false;
  }
}

class Program
{
  public static void Main(string[] args)
  {
    Class1 obj1 = new Class3();
    Class2 obj2 = new Class4();

    bool a,b;

    a = obj1.Test();
    b = obj2.Test();
    Console.WriteLine("a = " + a.ToString());
    Console.WriteLine("b = " + b.ToString());
  }
}

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback