+ 2

Explain please Polymorphism concept using example ?

java, polymorphism

9th Jul 2016, 9:14 AM
Vinod Luhar
5 ответов
+ 4
polymorphism means having different forms. in java, one object can take up many forms and is achieved using method overloading. for example method show() and show( int a) are different.
9th Jul 2016, 9:56 AM
Ashhar Mohd
Ashhar Mohd - avatar
0
Thanks Ashhar
9th Jul 2016, 10:01 AM
Vinod Luhar
0
please rate my question
9th Jul 2016, 10:02 AM
Vinod Luhar
0
For example if you have interface Sport and you implement classes Chess and Football.if somewhere in code you call method isGameWithBall() (this method is part of interface Sport) on variable which type is Sport interface how Java knows with which code sholud bind this method call.for method in class Chmetho or for method in class Football?in this scenario java use late binding - in runtime decide which code to call.for programmer point of view this is polymorphism.when you call method but that mehod can call different code in runtime.have a nice day;-)
9th Jul 2016, 11:26 AM
vetarikisa
0
polymorphism is really interesting topic. let me clear you with a task. I told you to give my message to 'rajiv' from class 8th, but you don't know 'rajiv' n even no one told you how's he look. than u just go to the 8th class and announce name the boy came up. and you will give him the message, but it didn't work when there are two or more 'rajiv' in same class. I need to clarify you with extra Attributes or behaviour of 'rajiv' whom I want to pass my message( like what he wear today, or have long hair, height 3.9 ft etc..etc, color, body type or anything else for distinguishing.) the above example is kind of function overloading type of polymorphism. there are different methods with same name but accessing exact the one with following description provided at call time).
24th Jul 2016, 5:04 AM
jayesh malviya
jayesh malviya - avatar