Regarding static and dynamic binding in Java
<p>Please explain the concept of static and dynamic binding in Java.</p>

<p>What I have grasped is that Static binding in Java occurs during compile time while dynamic binding occurs during Runtime, static binding uses Type (Class in Java) information for binding while dynamic binding uses Object to resolve binding.</p>

<p>This is the code for my understanding.</p>

<pre><code>    public class StaticBindingTest {

    public static void main (String args[])  {
       Collection c = new HashSet ();
       StaticBindingTest et = new StaticBindingTest();
       et.sort (c);         
    }

    //overloaded method takes Collection argument
    public Collection sort(Collection c) {
        System.out.println ("Inside Collection sort method");
        return c;
    }     

   //another overloaded method which takes HashSet argument which is sub class
    public Collection sort (HashSet hs){
        System.out.println ("Inside HashSet sort method");
        return hs;
    }         
}
</code></pre>

<p>and the output of the above program was inside the collection sort method</p>

<p>for dynamic binding...</p>

<pre><code>    public class DynamicBindingTest {

    public static void main(String args[]) {
        Vehicle vehicle = new Car(); //here Type is vehicle but object will be Car
        vehicle.start();       //Car's start called because start() is overridden method
    }
}

class Vehicle {

    public void start() {
        System.out.println("Inside start method of Vehicle");
    }
}

class Car extends Vehicle {

    @Override
    public void start() {
        System.out.println ("Inside start method of Car");
    }
}
</code></pre>

<p>the output was inside the start method of Car. Please advise: Is this understanding correct and please advise some more examples. Thanks.</p>
