get the app get the app       get the app       get the app
class A
{
public virtual void show()
{
Console.WriteLine("Hello: Base Class!");
Console.ReadLine();
}
}

class B : A
{
public override void show()
{
Console.WriteLine("Hello: Derived Class!");
Console.ReadLine();
}
}

class Polymorphism
{
public static void Main()
{
A a1 = new A();
a1.show();
B b1 = new B();
b1.show();
A a2 = new B();
a2.show();
}
}

1)Hello: Base Class!
Hello: Base Class!
Hello: Derived Class!

2)Hello: Base Class!
Hello: Derived Class!
Hello: Derived Class!

3)Hello: Base Class!
Hello: Derived Class!
Hello: Base Class!

4)Hello: Base Class!
Hello: Base Class!
Hello: Base Class!


  • : 272
  • : 1
    Previous Next

    Hello: Base Class!
    Hello: Derived Class!
    Hello: Derived Class!

    Suggest other answer
    Login to Discuss/suggest the answer...

  • Exam: OOPS Interview QUESTIONS





    Close(X)
    Subscribe here for free mock test on IAS PCS SSC and other competitive exam. Signup here to get SSC CGL Solution and main exam study material