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 ...
随机推荐
- ID3算法(决策树)
一,预备知识: 信息量: 单个类别的信息熵: 条件信息量: 单个类别的条件熵: 信息增益: 信息熵: 条件熵:(表示分类的类,表示属性V的取值,m为属性V的取值个数,n为分类的个数) 二.算法流程: ...
- java笔记5之逻辑运算符以及&&与&的区别
1 &逻辑与:有false则false. |逻辑或:有true则true. ^逻辑异或:相同为false,不同为true. 举例:情侣关系 ...
- MYSQL数据备份与还原学习笔记
数据备份与还原 1.mysqldump 1.1 文件地址: E:\xampp\mysql\bin 文件名:mysqldump.exe CMD下进入mysqldump.exe cd E:\xampp ...
- MYSQL视图的学习笔记
MYSQL视图的学习笔记,学至Tarena金牌讲师,金色晨曦科技公司技术总监沙利穆 课程笔记的综合. 视图及图形化工具 1. 视图的定义 视图就是从一个或多个表中,导出来的表,是一个虚 ...
- 基于MFC的socket编程(异步非阻塞通信)
对于许多初学者来说,网络通信程序的开发,普遍的一个现象就是觉得难以入手.许多概念,诸如:同步(Sync)/异步(Async),阻塞(Block)/非阻塞(Unblock)等,初学者往往迷惑不清, ...
- Java基础知识强化65:基本类型包装类之Integer的构造方法
1. Integer类概述 (1)Integer类在对象中包装了一个基本类型 int 的值,Integer类型的对象包含一个int类型的字段. (2)该类提供了多个方法,能在int类型和String类 ...
- JQuery 获取checkbox被选中的值
html代码 <ul id="dxbox"> <li><input type=" ...
- Android开发:碎片Fragment完全解析fragment_main.xml/activity_main.xml
Android开发:碎片Fragment完全解析 为了让界面可以在平板上更好地展示,Android在3.0版本引入了Fragment(碎片)功能,它非常类似于Activity,可以像 Activi ...
- .net ADF 中 Ajax 的调用过程.
图示是 .net ADF Ajax调用过程的简略过程: 1,2)当页面初始化之后, 浏览器一旦触发回调事件, 脚本函数负责处理回调信息, 并调用 ASP.NET 2.0/3.5 中的 WebForm_ ...
- SQlserver表连接
连接是两元运算,可以对两个或多个表进行查询,结果通常是含有参加连接运算的两个表或多个表的指定列的表. 在T-SQL中,连接查询有两类: 第一类:符合SQL标准的连接谓词表示形式: 第二类:T-SQL扩 ...