Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5977873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:26:00+00:00 2026-05-22T21:26:00+00:00

Overriding is a principle that allows you to change the functionality of a method

  • 0

Overriding is a principle that allows you to change the functionality of a method in a child class.

For Ex.

//Overriding
public class test
{
        public virtual getStuff(int id)
        {
            //Get stuff default location
        }
}

public class test2 : test
{
        public override getStuff(int id)
        {
            //base.getStuff(id);
            //or - Get stuff new location
        }
}

When we Inherit test class in test2 at that time compiler knows that there is a virtual method in parent class.
Then why Method overring is runtime bound and not compile time bound?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:26:01+00:00Added an answer on May 22, 2026 at 9:26 pm

    It is run-time binding (if that is even the right phrasing – I’m not convinced) because even with a test2 variable you could actually have:

    test2 obj = new test3(); // imagine test3 inherits from test2
    obj.getStuff(id);
    

    here the variable is a test2, but the object is a test3. You could argue that maybe if it was sealed etc, but actually even non-virtual instance (non-static) methods go through the callvirt process. It works well, and is very fast. Additionally, the callvirt opcode has the necessary null-check, which means your code doesn’t (under the bonnet) have to constantly check for nulls (which would be necessary if it was static-call)

    The only exception here is structs which override an object method; the following is a static call:

    int i = 1;
    string s = i.ToString();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to avoid overriding? public partial class test : System.Web.UI.Page { StringBuilder sb =
When overriding a virtual method, I noticed that when I make a mistake in
I understand overriding a method/function redefines its implementation in the derived class from its
When overriding a class in C++ (with a virtual destructor) I am implementing the
I noticed that when overriding virtual methods in C# using Visual Studio, the IDE
When overriding a non-virtual method in Java, use of the @Override annotation is recommended,
Normal overriding would work this way: class Fruit { public: string color(); }; string
I'm overriding a property in my derived class that I would like to make
I know that overriding the back button functionality is not considered a good user
This question demonstrates that overriding an Ember.View instance's didInsertElement allows you to execute some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.