What are static and dynamic binding

Attaching a method call to the body of a method is called binding. If the binding is done by the compiler (linker) before starting the program, then it is called static or early binding.

In turn, late binding is binding carried out directly at runtime, depending on the type of object. Late binding is also called dynamic or runtime binding. In languages ​​that implement late binding, there must be a mechanism for determining the actual type of an object at runtime to invoke the appropriate method. In other words, the compiler does not know the type of the object, but the method invocation mechanism determines it and calls the corresponding method body. Late-binding is language-specific, but it's not hard to assume that some additional information must be included in objects to implement it.

All Java methods use late (dynamic) binding, unless the method has been declared final (private methods are final by default).


Read also:


Comments

Popular posts from this blog

Methods for reading XML in Java

XML, well-formed XML and valid XML

ArrayList and LinkedList in Java, memory usage and speed