C# Programming - Polymorphism - Discussion

Discussion :: Polymorphism - General Questions (Q.No.3)


Which of the following keyword is used to change the data and behavior of a base class by replacing a member of a base class with a new derived member?

[A]. new
[B]. base
[C]. overloads
[D]. override
[E]. overridable

Answer: Option A


No answer description available for this question.

Sreejith said: (May 17, 2012)  
But what about the override keyword. Is it that it is used only in cases where abstract and virtual functions are defined?

Vasu said: (Jul 6, 2012)  

For replacing a member of a base class we use "new" keyword but redefine a member of a bass class we use "override".

Ajay said: (Jun 9, 2013)  

When we declare a member function with new keyword in derived class it means we are hiding the behavior of base class member function in derived class and implement new behavior for a member function in derived class. Derived class member function behavior does not override with base class member function.

But when we use override keyword with derived class member function means we are replacing the behavior the base class member function in derived class.

Babaaa said: (Nov 26, 2013)  
Can we use another keyword?

Chitharanjan said: (Mar 20, 2014)  
Writing 'new' keyword for a method in derived class won't replace the method which is existing base class. This concept is called as 'Shadowing'. In this concept by default we can access derived Method and we can access the existing method also.

Siddharth said: (Nov 21, 2014)  
We can also use 'new' keyword for object creation.

Pankaj Singh said: (Jun 18, 2016)  
I think the override is the correct answer.

Prasad said: (Dec 1, 2017)  
Yes, t is hiding/shadowing method.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.