The Artima Developer Community
Sponsored Link

Java Buzz Forum
Static vs Dynamic Binding in Java | Difference between Compile time and Runtime Binding

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Javin Paul

Posts: 1090
Nickname: javinpaul
Registered: Jan, 2012

Javin Paul is Java Programmer working on Finance domain.
Static vs Dynamic Binding in Java | Difference between Compile time and Runtime Binding Posted: Feb 14, 2014 8:24 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Javin Paul.
Original Post: Static vs Dynamic Binding in Java | Difference between Compile time and Runtime Binding
Feed Title: Java67
Feed URL: http://www.java67.com/feeds/posts/default?alt=rss
Feed Description: Java and technology tutorials, tips, questions for all programmers.
Latest Java Buzz Posts
Latest Java Buzz Posts by Javin Paul
Latest Posts From Java67

Advertisement
When you call a method in Java, it is resolved either at compile time or at runtime, depending upon whether its a virtual method or a static method. When a method call is resolved at compile time, it is known as static binding, while if method invocation is resolved at runtime, it is known as Dynamic binding or Late binding. Since Java is an object oriented programming language and by virtue of that it supports Polymorphism. Because of polymorphism, a reference variable of type Parent can hold an object of type Child, which extends Parent. Now if you call a virtual method (not private, final or static) on this object, then Compiler can not find actual method, because it could be the one, which is defined in Parent class, or the one which Child has overridden. This call can only be resolved at runtime, when actual object is available. That's why this is known as runtime or dynamic binding. On the hand, private, static and final methods are resolved at compile time, because compiler knows that they can't be overridden and only possible methods are those, which are defined inside a class, whose reference variable is used to call this method. This is known as static or compile time binding, all private, static and final methods are resolved using static binding. This concept is also closely related to method overloading and method overriding. As dynamic binding happens when method overriding is possibility and overloaded method calls are resolved at compile time, because they are always defined in same class. In this article, we will learn few more difference between Static and Dynamic Binding in Java, but before this let's see couple of examples of static and dynamic binding :
Read more ยป

Read: Static vs Dynamic Binding in Java | Difference between Compile time and Runtime Binding

Topic: Code Katas Previous Topic   Next Topic Topic: Everything about Java 8

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use