Margaret Rouse is an award-winning technical writer and teacher known for her ability to explain complex technical subjects simply to a non-technical, business audience. Over…
Overriding is an object-oriented programming feature that enables a child class to provide different implementation for a method that is already defined and/or implemented in its parent class or one of its parent classes. The overriden method in the child class should have the same name, signature, and parameters as the one in its parent class.
Overriding enables handling different data types through a uniform interface. Hence, a generic method could be defined in the parent class, while each child class provides its specific implementation for this method.
The invoked method version is determined by the class object. If the child class object is used to invoke the method, then the child class version of the method is executed. If the parent class object is used to invoke the method, then the parent class version of the method is executed. The invoked method is determined at runtime, whereas in overloading, the invoked method is determined at compile time.
C++ and C# support overriding by explicitly using the keywords ‘override’ and ‘virtual’. Java uses the ‘super’ keyword to invoke the superclass method. However, C++ does not have the super keyword and uses instead the base class name followed by the scope resolution operator (::).
Techopedia’s editorial policy is centered on delivering thoroughly researched, accurate, and unbiased content. We uphold strict sourcing standards, and each page undergoes diligent review by our team of top technology experts and seasoned editors. This process ensures the integrity, relevance, and value of our content for our readers.
Margaret is an award-winning technical writer and teacher known for her ability to explain complex technical subjects to a non-technical business audience. Over the past twenty years, her IT definitions have been published by Que in an encyclopedia of technology terms and cited in articles by the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine, and Discovery Magazine. She joined Techopedia in 2011. Margaret's idea of a fun day is helping IT and business professionals learn to speak each other’s highly specialized languages.
What is GitHub? GitHub is a vast platform that changes how software developers work together on projects. It's more than...
Maria WebbTechnology journalist
What is CALMS? CALMS stands for Culture, Automation, Lean, Measurement, and Sharing. It is a framework widely recognized in the...
Marshall GunnellIT & Cybersecurity Expert
What is a Pull Request? A pull request, often abbreviated as PR, is a feature in version control systems like...
Trending NewsLatest GuidesReviewsTerm of the Day