Difficulty: Easy
Correct Answer: virtual
Explanation:
Introduction / Context:In C#.NET, runtime polymorphism depends on whether the base member is declared in a way that permits overriding. If the base member does not allow overrides, a derived class cannot truly replace its behavior polymorphically.
Given Data / Assumptions:
Concept / Approach:The base class must mark a method or property as virtual (or abstract). A derived class then uses override to supply the new implementation. Using new merely hides a member at compile time but does not participate in dynamic dispatch through a base reference.
Step-by-Step Solution:
1) Base declares: virtual void M() { /* base */ }2) Derived declares: override void M() { /* derived */ }3) Calling M() through a Base reference bound to a Derived object invokes Derived.M().Verification / Alternative check:Test with Base b = new Derived(); b.M(); and observe the derived implementation executing.
Why Other Options Are Wrong:
Common Pitfalls:Confusing new with override leads to unexpected base behavior when using base-typed references.
Final Answer:virtual
Discussion & Comments