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 1045491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:59:37+00:00 2026-05-16T15:59:37+00:00

Consider the following code: public class Vehicle { public void StartEngine() { // Code

  • 0

Consider the following code:

public class Vehicle
{
    public void StartEngine()
    {
        // Code here.
    }
}

public class CityBus : Vehicle
{
    public void MoveToLocation(Location location)
    {
        ////base.StartEngine();
        this.StartEngine();
        // Do other stuff to drive the bus to the new location.
    }
}

Is there any difference between this.StartEngine(); and base.StartEngine();, except that in the second case, StartEngine method cannot be moved to or overridden in CityBus class? Is there a performance impact?

  • 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-16T15:59:37+00:00Added an answer on May 16, 2026 at 3:59 pm

    The only difference is an explicit call to look at your parent class versus an implicit one that ends up in the same place through simple inheritance. Performance difference is negligible. like Hans Passant said, a call to base.StartEngine() will cause weird behavior if you make StartEngine virtual at some point.

    You shouldn’t need either qualifier to get the the right place. this.StartEngine() is almost always redundant when explicitly coded. You may have code that indirectly puts a this reference in a list of objects, but then it’s the reference in the list being called:

    public class Vehicle
    {
        public void StartEngine()
        {
            // Code here.
        }
    
        //For demo only; a method like this should probably be static or external to the class
        public void GentlemenStartYourEngines(List<Vehicle> otherVehicles)
        {
           otherVehicles.Add(this);
    
           foreach(Vehicle v in Vehicles) v.StartEngine();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following code: public abstract class Base { public void getAnswer(); } public
Consider the following code: class Base { public: virtual void Foo() {} }; class
Consider the following code: class A { public: virtual void f() throw ( int
Consider the following C++ code: class A { public: virtual void f()=0; }; int
Consider the following code :- public class UsingWait1{ public static void main(String... aaa){ CalculateSeries
Consider the following sample code: class MyClass { public long x; public void DoWork()
Consider the following code: public class ReadingTest { public void readAndPrint(String usingEncoding) throws Exception
Consider the following code, public class StartUp { public StartUp(String[] test){} public static void
Consider the following code : public class Main implements Vehicle, Car { public static
Consider the following code (C# 4.0): public class Foo : LambdaExpression { } This

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.