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

  • Home
  • SEARCH
  • 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 6026815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:30:00+00:00 2026-05-23T04:30:00+00:00

For the following segment of java code, the method of run occurs four times.

  • 0

For the following segment of java code, the method of “run” occurs four times. I am quite confusing about the relationships of these four occurrences of “run”. The original code is pretty long, I just keep the part that is related to my question.

   1. public final class Job extends AbstractJob {  
   2.   private Job( ) {  
   3.   }  
   4.   public static void main(String[] args) throws Exception {    
   5.            new Job( ).run(new Path("testdata"), output, 10 );  
   6.   }  
   7.   
   8.   @Override  
   9.   public int run(String[] args) throws IOException, ClassNotFoundException,      InterruptedException {  
  10.         run(input, output, alpha0);  
  11.         return 0;  
  12.   }    
  13.   public void run(Path input,  Path output,  double alpha0)  
  14.     throws IOException, ClassNotFoundException, InterruptedException {      
  15.     ClusterDriver.run(directoryInput, output, alpha0);      
  16.   }  
  17. }  

Can I understnd the invoking sequence of this segment of code as follows.

At first, he run method at line 5 is called. Due to its particular parameter setting, 3 parameters, the compiler automatically uses the run method defined in line 13. ( if we only have one parameter in line 5, then compiler will use the run method defined in line 9 instead.

For the run method defined in line 9, it will call run method at line 10, which essentially is the run method defined at line 13.

Is my understanding correct?

  • 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-23T04:30:01+00:00Added an answer on May 23, 2026 at 4:30 am

    Your basic analysis is correct.

    (just to clarify the point that others have made: overloading is when methods have the same name but different signatures, whereas overriding is when a method has the same name and argument types as a method in a superclass)

    For future reference, you should be aware that method resolution (name + arguments -> method selection) in Java, in the case of overloaded methods, can actually be quite difficult to understand. The exact behavior used is written up in the Java Language Spec (JLS), section 15.12, and involves a few general subtleties:

    • Overloaded method resolution is done at compile time, not at runtime. (selection among method overrides with the same signature is done at runtime, based on the most specific subclass’s method.) If the compiler knows an argument is an instance of Foo (e.g. its class is Foo or a subclass of Foo) then it will use Foo as the argument’s class, not its “real” class.

    • Issues that determine which method is used include:

      • whether a method is varargs or not (has ... as the last argument e.g. foo(Object a, String... b))
      • whether a method’s declared arguments are primitives or wrapped primitives e.g. float vs Float
      • whether one method’s declared arguments are “more specific” than another (subclasses are more specific than their superclasses)

    This is complex but you have the basic understanding.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I try to debug the following function segment, the execution brakes (jumps out
Following Izb's question about Best binary XML format for JavaME , I'm looking for
Following is some obviously-defective code for which I think the compiler should emit a
So I use Paint's measureText() method to measure the width of a segment of
Following on from my recent question on Large, Complex Objects as a Web Service
Following my question regarding a .NET YAML Library ... as there doesn't seem to
Following this question: Good crash reporting library in c# Is there any library like
Following on from this question what would be the best way to write a
Following techniques from 'Modern C++ Design', I am implementing a persistence library with various
Following up on this question, I'm working on a large Delphi 7 codebase which

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.