-- Concept of exhibiting different behaviours in different situations by a method is known as polymorphism.
There are 2 types of polymorphism.
1.Method or static polymorphism
2.Object or dynamic polymorphism
Static polymorphism :
-- Here the same method will give different result based on the arguments that we are passing so this is known as method polymorphism.
-- which method has to be executed will be decided by the compiler during the compilation is known as static polymorphism.
-- We can achieve the method polymorphism using method overloading.
-- compiler it self will decide which method has to be executed first is known as“StaticPolymarphism”
Method overloading or method overwriting:-
--Concept of defining a method with same name and with different signatures is known as method overloading.
Dynamic Polymorphism :
-- Same method will give different result based on the object acting upon it.(object polymorphism)
-- In this case which method has to be executed will be decided by the jvm during runtime(dynamic)
-- We can achieve dynamic polymorphism by using method overriddenig.
Method overriding :
-- Concept of defining the same method with same signature inside the subclass.
There are 2 types of polymorphism.
1.Method or static polymorphism
2.Object or dynamic polymorphism
Static polymorphism :
-- Here the same method will give different result based on the arguments that we are passing so this is known as method polymorphism.
-- which method has to be executed will be decided by the compiler during the compilation is known as static polymorphism.
-- We can achieve the method polymorphism using method overloading.
-- compiler it self will decide which method has to be executed first is known as“StaticPolymarphism”
Method overloading or method overwriting:-
--Concept of defining a method with same name and with different signatures is known as method overloading.
Dynamic Polymorphism :
-- Same method will give different result based on the object acting upon it.(object polymorphism)
-- In this case which method has to be executed will be decided by the jvm during runtime(dynamic)
-- We can achieve dynamic polymorphism by using method overriddenig.
Method overriding :
-- Concept of defining the same method with same signature inside the subclass.
No comments:
Post a Comment