can't really find the proper answer. if we have:
1.Animal cat = new Cat();
2.Animal animal = new Animal();
Animal and Cat both has method makeSound();
1.as I understand early binding in Java happens during compile time and method call is bound depending on the reference type. so during compile time it makes decision to call method from Animal.
then we have runtime and it appears that the real object is Cat and there's an overriden method there and at this point late biding takes place?
my question will java first makes static binding and then during runtime checks again the actual object and rebind again?
They say compile binding is faster than runtime, but it looks like runtime binding will be involved anyway even if there's no overriden method in Cat? looks like overhead
- in the second case, no sense for Java to check the actual object? or it will check anyway?
also will annotation @Override somehow helps to make that decision?
I tried to Google and couldn't really find the straight answer and chat GPT messed me up completely