title: Overloading is compile-time polymorphism. Really?
body: <p>I do know the syntactical difference between overriding and overloading. And I also know that overriding is run-time polymorphism and overloading is compile-time polymorphism. But my question is: "Is overloading is really compile-time polymorphism? Is the method call really solving at compile time?". To clarify my point, let's consider an example class.</p>
  
  <pre><code>public class Greeter {
      public void greetMe() {
          System.out.println("Hello");
      }
  
      public void greetMe(String name) {
          System.out.println("Hello " + name);
      }
  
      public void wishLuck() {
          System.out.println("Good Luck");
      }
  }
  </code></pre>
  
  <p>Since all of the methods <code>greetMe(), greetMe(String name), wishLuck()</code> are public, they all can be overriden(including overloaded one), right? For example,</p>
  
  <pre><code>public class FancyGreeter extends Greeter {
      public void greetMe() {
          System.out.println("***********");
          System.out.println("*  Hello  *");
          System.out.println("***********");
      }
  }
  </code></pre>
  
  <p>Now, consider the following snippet:</p>
  
  <pre><code>Greeter greeter = GreeterFactory.getRandomGreeter();
  greeter.greetMe();
  </code></pre>
  
  <p>The <code>getRandomGreeter()</code> method returns a random <code>Greeter</code> object. It may either return an object of <code>Greeter</code>, or any of its subclasses, like <code>FancyGreeter</code> or <code>GraphicalGreeter</code> or any other one. The <code>getRandomGreeter()</code> will create the objects either using <code>new</code> or dynamically load the class file and create object using reflection(I think it is possible with reflection) or any other way that is possible. All of these methods of <code>Greeter</code> may or may not be overriden in subclasses. So the compiler has no way to know whether a particular method(overloaded or not) is overriden. Right? Also, wikipedia says on <a href="http://en.wikipedia.org/wiki/Virtual_function#Java" rel="noreferrer">Virtual functions</a>:</p>
  
  <blockquote>
    <p>In Java, all non-static methods are by default "virtual functions". 
        Only methods marked with the keyword final, which cannot be overridden, 
        along with private methods, which are not inherited, are non-virtual.</p>
  </blockquote>
  
  <p>Since, virtual functions are resolved at run-time using dynamic method dispatch, and since all non private, non final methods are virtual(whether overloaded or not), they must be resolved at run-time. Right?</p>
  
  <p>Then, How can overloading still be resolved at compile-time? Or, is there anything that I misunderstood, or am I missing?</p>