Vamsi
Vamsi

Reputation: 4263

What is virtual polymorphism?

I know about polymorphism and the keyword virtual in C#.net, but i don't know what is Virtual polymorphism, I was asked this question in a interview yesterday.

Thank you

Upvotes: 1

Views: 4178

Answers (3)

Manish Basantani
Manish Basantani

Reputation: 17509

Either....

They meant "runtime polymorphism" (late binding) (so as to know if you know the difference between compile-time and runtime polymorphism).

Or...

The question was fired to confuse you.

Upvotes: 2

Stefan Steinegger
Stefan Steinegger

Reputation: 64658

There are concepts like:

I've never heard about virtual polymorphism. In most modern programming languages, these concepts are strongly related. IMHO, it's very academic to distinguish them (I mean: inheritance, virtual inheritance, polymorphism, subtype polymorphism).

Upvotes: 1

Embedd_0913
Embedd_0913

Reputation: 16565

There is nothing called virtual polymorphism.

You can achieve polymorphism by using virtual methods in C#.

That means if you declare a method virtual in base class you can override that method in child/derived classes to change it's behavior.

class Base
    {
        public virtual void SayHello()
        {
            Console.WriteLine("Hello from base");
        }
    }

    class Derived : Base
    {
        public override void SayHello()
        {
            Console.WriteLine("Hello from derived");
        }
    }

Upvotes: 2

Related Questions