Static Binding and Dynamic Binding
Connecting a method call to the method body is known as binding.
There are two types of binding
Let's understand the type of instance.
1) variables have a type
Each variable has a type, it may be primitive and non-primitive.
Here data variable is a type of int.
2) References have a type
3) Objects have a type
When type of the object is determined at compiled time(by the compiler), it is known as static binding.
If there is any private, final or static method in a class, there is static binding.
Example of static binding
When type of the object is determined at run-time, it is known as dynamic binding.
Example of dynamic bindingTest it Now
Output:dog is eating...