Which keyword is used to indicate that a method can be overridden?

Prepare for the MTA Software Development Fundamentals Exam! Access flashcards, multiple-choice questions, and detailed explanations to enhance your learning and ace your exam.

The keyword that indicates a method can be overridden is "virtual." In object-oriented programming, especially in languages like C#, a method declared as virtual allows derived classes to provide their own implementation for that method, effectively overriding the base class's implementation.

When a method is marked as virtual, it means that the method's behavior can be changed in any subclass that inherits from the class containing the virtual method. This is a key feature of polymorphism in object-oriented programming, as it enables a more flexible and dynamic response to method calls depending on the runtime type of the object.

In contrast, other options serve different purposes. The keyword "new" is used to hide a member of the base class instead of actually overriding it. "Override" is used in the derived class to specify that a method is intended to override a virtual method in the base class. The "sealed" keyword is used to prevent further overriding of a method that has already been overridden, thereby locking its implementation in the derived class.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy