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

Let's observe the following segment of code in Java that uses System.currentTimeMillis() in a
The following code segment get an output of 32, I am kind of confusing
The following segment of code shows JOptionPane.showInputDialog() method. It works fine, Now I want
Having trouble with the following segment of code. I'm getting a parameter count mismatch.
I have two identical byte arrays in the following segment of code: /// <summary>
I created a new project with the following code segment: char* strange = (Strange??);
I have a controller class as in the following code segment: @Controller public class
Consider the following C code segments. Segment 1: char * getSomeString(JNIEnv *env, jstring jstr)
Say I have the following piece of java code ArrayList<Double> myList = new Double[100];
I have the following code segment: var framelist = BL.FooBL.GetFrame() ; var foreach( var

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.