Dynamic Binding & Static Binding
Reference: JavaPoint BeginnerBook
What is Binding
Connecting a method call to the method body is known as binding.
There are two types of binding
- static binding (also known as early binding): binding solved at compile time
- dynamic binding (also known as late binding): binding solved at runtime
Static Binding
The binding which can be resolved at compile time by compiler is known as static or early binding.
All the static, private and final methods have always been bonded at compile-time .
- Why binding of Static, final and private methods is always a static binding?
- Compiler knows that all such methods cannot be overridden and will always be accessed by object of local class. Hence compiler doesn’t have any difficulty to determine object of class (local class for sure). That’s the reason binding for such methods is static.
Dynamic Binding
When compiler is not able to resolve the call/binding at compile time, such binding is known as Dynamic or late Binding.
Overriding is a perfect example of dynamic binding as in overriding both parent and child classes have same method. Thus while calling the overridden method, the compiler gets confused between parent and child class method(since both the methods have same name).
Key Points
- Static binding happens at compile-time while dynamic binding happens at runtime.
- Binding of private, static and final methods always happen at compile time since these methods cannot be overridden. Binding of overridden methods happen at runtime.
- Java uses static binding for overloaded methods and dynamic binding for overridden methods.
Dynamic Binding & Static Binding的更多相关文章
- static binding/dynamic binding
static binding/dynamic binding class Person { private void who() { System.out.println("Inside p ...
- get_called_class--后期静态绑定("Late Static Binding")类的名称
get_called_class--后期静态绑定("Late Static Binding")类的名称 string get_called_class ( void ) 获取静态方 ...
- php中的后期静态绑定("Late Static Binding")
在我们以往中,在类中使用self关键字的时候都是指向了被调用方法定义时的类,而非原始的调用类. 例如: class Animal{ static $IQ_lv_avg = 1; public stat ...
- Unity3D - 关于Dynamic和Static
含有Collider和RigidBody的GameObject, Unity视之为Dynamic 含有Collider的GameObject, Unity视之为Static 如果Static的物体发生 ...
- hive parition的使用,分dynamic和static两种
partition是hive提供的一种机制:用户通过指定一个或多个partition key,决定数据存放方式,进而优化数据的查询 一个表可以指定多个partition key,每个partition ...
- 绑定 Binding Path=.,Binding.,Binding Source={StaticResource ResourceKey="Hello"} xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:sys="clr-namespace:System;assembly=mscorlib" <Window.Resources> <Style Targ ...
- manually Invoking Model Binding / Model Binding /Pro asp.net mvc 5
限制绑定器 数据源
- Java Knowledge series 4
JVM & Bytecode Has-a or Is-a relationship(inheritance or composition) 如果想利用新类内部一个现有类的特性,而不想使用它的接 ...
- Java Knowledge series 1
Programming language evolves always along with Compiler's evolvement JVM as Additional Indirection I ...
随机推荐
- Android中theme.xml与style.xml的区别
一.相同点 两者的定义相同.继承方式也相同 <?xml version="1.0" encoding="utf-8"?> <resources ...
- oracle中 connect by prior 递归算法
Oracle中start with...connect by prior子句用法 connect by 是结构化查询中用到的,其基本语法是: select ... from tablename sta ...
- iPhone应用程序间传递数据
前一篇简单的介绍了iPhone应用程序间通信,主要是通过在被调用应用的Info.plist中加入URL方案,在应用中通过openUrl来实现程序的调用.而应用程序间的数据传递则可以更具url来实现,例 ...
- c++Socket 异步通讯
在网络通讯中,由于网络拥挤或一次发送的数据量过大等原因,经常会发生交换的数据在短时间内不能传送完,收发数据的函数因此不能返回,这种现象叫做阻塞. Winsock对有可能阻塞的函数提供了两种处理方式:阻 ...
- Aspose.Cells for .NET 8.5.0 工具类
基于 Aspose.Cells for .NET 8.5.0 工具类, Aspose.Cells for .NET 8.5.0 这个自己去CSDN下载里面有破解的,没有破解的导出excel的时候会(A ...
- 函数malloc的实现源代码
/****************************************************************Copyright 1990, 1994, 2000 by AT&am ...
- zookeeper端口号冲突:8080冲突
端口号冲突,在conf/zoo2181.cfg文件里面添加一个端口号的指定(具体的端口号可以自己定义一个): admin.serverPort=8081
- 为什么子线程不能做UI操作
在子线程中是不能进行UI 更新的,而可以更新的结果只是一个幻像:因为子线程代码执行完毕了,又自动进入到了主线程,执行了子线程中的UI更新的函数栈,这中间的时间非常的短,就 让大家误以为分线程可以更新U ...
- JavaScript学习笔记(三十八) 复制属性继承
复制属性继承(Inheritance by Copying Properties) 让我们看一下另一个继承模式—复制属性继承(inheritance by copying properties).在这 ...
- 转载:[Java]读取文件方法大全
转载网址:http://www.cnblogs.com/lovebread/archive/2009/11/23/1609122.html 1.按字节读取文件内容 2.按字符读取文件内容 3.按行读取 ...