adisharma Posted February 24, 2022 Share Posted February 24, 2022 Hello Everyone, I'm currently doing an assignment for one of my classes, and in it, I have to give examples, using Java syntax, of *static* and *dynamic binding*. I am lost while understanding the work process. I understand the basic concept, that static binding happens at compile time and dynamic binding happens at runtime, but I can't figure out how they actually work specifically. I found an example of static binding online that gives this example and running the program on interviewbit. public static void callEat(Animal animal) { System.out.println("Animal is eating"); } public static void callEat(Dog dog) { System.out.println("Dog is eating"); } public static void main(String args[]) { Animal a = new Dog(); callEat(a); } And that this would print "animal is eating" because *the call to `callEat` uses static binding* , but I'm unsure as to *why* this is considered static binding. So far none of the sources I've seen have managed to explain this in a way that I can follow. Can anyone suggest me? 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.