static-binding

Static Binding and Dynamic Binding

与世无争的帅哥 提交于 2019-11-26 07:26:48
问题 I am really confused about dynamic binding and static binding. I have read that determining the type of an object at compile time is called static binding and determining it at runtime is called dynamic binding. What happens in the code below: Static binding or dynamic binding? What kind of polymorphism does this show? class Animal { void eat() { System.out.println(\"Animal is eating\"); } } class Dog extends Animal { void eat() { System.out.println(\"Dog is eating\"); } } public static void

What is the difference between Early and Late Binding?

瘦欲@ 提交于 2019-11-26 03:33:39
问题 What is the difference between early and late binding? 回答1: The short answer is that early (or static) binding refers to compile time binding and late (or dynamic) binding refers to runtime binding (for example when you use reflection). 回答2: In compiled languages, the difference is stark. Java: //early binding: public create_a_foo(*args) { return new Foo(args) } my_foo = create_a_foo(); //late binding: public create_something(Class klass, *args) { klass.new_instance(args) } my_foo = create