I am really confused about dynamic binding and static binding. I have read that determining the type of an object at compile time is called static binding and determining it
check this
employee class has abstract earning() function and each class has deferent toString() implementation
Employee[] employees = new Employee[4];
// initialize array with Employees
employees[0] = new SalariedEmployee();
employees[1] = new HourlyEmployee();
employees[2] = new CommissionEmployee();
employees[3] = new BasePlusCommissionEmployee();
for (Employee currentEmployee : employees){
System.out.println(currentEmployee); // invokes toString
System.out.printf("earned $%,.2f%n", currentEmployee.earnings());
}
All calls to method toString and earnings are resolved at execution time, based on the type of the object to which currentEmployee refers,
This process is known as dynamic binding or late binding
reference: Java™ How To Program (Early Objects), Tenth Edition