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 ...
随机推荐
- React问答小demo
在学习react初期,看了一些视频和资料,react基础知识差不多学完,跟着网上的一个教程,做了一个小型的问答demo. 需求看图说: 1.点击"添加"按钮,显示问题输入表单,再次 ...
- Python模拟登录实战(一)
今天,学习了模拟登录新浪微博.模拟登录主要有两种方式,一.利用Cookie:二.模仿浏览器的请求,发送表单. 法一: Cookie:指某些网站为了辨别用户身份而储存在用户本地终端上的数据(通常经过加密 ...
- URL中的空格字符如何编码
URL encoding the space character: + or %20? 简单理解: ‘?’前的路径中的空格必须为’20%’ ‘?’后的参数中空格可以被编码成’+’(正常情况),然而有时 ...
- Python学习--07迭代器、生成器
迭代 如果给定一个list或tuple,我们可以通过for循环来遍历这个list或tuple,这种遍历我们称为迭代(Iteration). Python里使用for...in来迭代. 常用可迭代对象有 ...
- (三)一个工作任务引起的乱战——udp通信
先上代码.该代码是在问度娘的过程中搜到的,自己实验运行了下,可以使用(vs2010 net fram4.0).服务端代码: using System;using System.Collections ...
- django: db - admin
本讲演示简单使用 Django Admin 功能. 一,修改 settings.py,添加 admin 应用: INSTALLED_APPS = ( 'django.contrib.auth', 'd ...
- 验证视图状态 MAC 失败。如果此应用程序由网络场或群集承载,请确保 <machineKey>
转自:http://hi.baidu.com/taotaowyx/blog/item/074bb8d83907bb3233fa1ce6.html 验证视图状态 MAC 失败.如果此应用程序由网络场或群 ...
- Android(工具・集成)
■ NDK Android从始(2009)至终是支持JNI的. 只不过一开始没有NDK.需要自己安装交叉编译器创建so,然后放到assert之类捆绑so发布. 有了NDK.有了什么? libc lib ...
- 学习OkHttp wiki--Interceptors
Interceptors 拦截器(Interceptors)是一种强有力的途径,来监控,改写和重试HTTP访问.下面是一个简单的拦截器,对流出的请求和流入的响应记录日志. class LoggingI ...
- Android-应用的本地化及知识拓展之配置修饰符
步骤很简单,只需要两步: 1.创建带有目标语言的配置修饰符的资源子目录 2.将可选资源放入该目录下,android系统会自动处理后续工作 在这里我们需要讲解一下配置修饰符. 中文的配置修饰符:-zh, ...