C# Programming - Polymorphism - Discussion

Discussion Forum : Polymorphism - General Questions (Q.No. 3)
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?
new
base
overloads
override
overridable
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
8 comments Page 1 of 1.

Sreejith said:   1 decade ago
But what about the override keyword. Is it that it is used only in cases where abstract and virtual functions are defined?

Vasu said:   1 decade ago
@Sree.

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:   1 decade ago
Hi,

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.
(1)

BABAAA said:   1 decade ago
Can we use another keyword?

Chitharanjan said:   1 decade ago
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:   1 decade ago
We can also use 'new' keyword for object creation.

Pankaj singh said:   9 years ago
I think the override is the correct answer.
(2)

Prasad said:   8 years ago
Yes, t is hiding/shadowing method.

Post your comments here:

Your comments will be displayed after verification.