Quston 1

C# Polymorphism and Method Hiding Quiz

C# Polymorphism and Method Hiding Quiz

1. What will the following code output?

            class Grandfather
            {
                public virtual void Display() { Console.WriteLine("Grandfather's display method."); }
            }
            class Father : Grandfather
            {
                public override void Display() { Console.WriteLine("Father's display method."); }
            }
            class Child : Father
            {
                public new void Display() { Console.WriteLine("Child's display method."); }
            }
            class Program
            {
                static void Main()
                {
                    Grandfather person = new Child();
                    person.Display();
                }
            }
        



2. What is the effect of using the 'new' keyword in the Child class for the Display method?




Comments

Popular posts from this blog

React Interview Questions - Controlled vs Uncontrolled

What is the closure function in Javascrpt(javascrpt)

gg