dynamic binding in java dynamic binding in java with example dynamic binding in java with realtime example
dynamic binding in java ppt dynamic binding in java pdf example for dynamic binding in java
Dynamic Binding:
1) Dynamic binding is one of the distinct
feature of Object Oriented Programming Concepts in java.
2) Dynamic binding always says “do not create an
object of derived class “ but create an object of
base class.
base class.
The advantage of dynamic
binding concept is to give less memory space and higer performance.
3) Dynamic binding use always polymorphism related
concepts.
Definition of
Dynamic Binding
The process of
binding appropriate versions of derived class which are inherited from base
class with base class object is known as Dynamic binding.
While we are using
dynamic binding at the time of executing polymorphism application jvm will
internally considers the following two points
a)
What type of object.
b)
What type of address.
In other words when we create an object
indirectly jvm internally considers
above two points.
The Following Program
illustrate the concept of Dynamic Binding
Class BaseDemo
{
Void fun1()
{
System.out.println(“this is fun1() of Base demo”);
}
}
Class DerviedDemo1
extends BaseDemo
{
Void fun1()
{
System.out.println(“this is fun1() of Derived demo1”);
}
}
Class DerivedDemo2
extends BaseDemo
{
Void fun1()
{
System.out.println(“this is fun1() of Derived demo2”);
}
}
Class demo
{
Public static void main(String args[])
{
BaseDemo BD=new
BaseDemo();
BD.fun1();
BaseDemo BD=new DerivedDemo1();
BD.fun1();
BaseDemo BD=new DerivedDemo2();
BD.fun1();
}
}
}
Analysis:
From the above program Consider these things BD contains
address of BaseDemo(), DerivedDemo1(), DerivedDemo2(). Hence BD is Polymorphic
object.
The method fun1() is available in one form and it is
redefined in multiple forms.Hence fun1() is known as polymorphic method.
The statement BD.fun1() is actually one statement but is
gives multiple results.Hence this statement is known as polymorphic statement.
No comments:
Post a Comment