polymorphism | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

polymorphism

easy way to understood what is polymorphism ??

16th Nov 2018, 3:01 PM
Mohammed farih
Mohammed farih - avatar
2 Answers
+ 2
Its where an object could be considered as different class at same time. For example you declare a class like this class A extends B implements C This way if we create an object from A, that object also valid as B and C A a=new A(); B b=a; C c=a; ps: its been a while i havent code in java, please correct me if i'm wrong
16th Nov 2018, 3:10 PM
Taste
Taste - avatar
+ 2
POLYMORPHISM is of two types , Function overloading that is also called method overloading and second is Method Overriding. In FUNCTION OVERLOADING, Methods have same name with different number of arguments or with different data types also. In METHOD OVERRIDING, Methods have same name with same number of arguments. METHOD OVERRIDING is only achieved by Inheritance and Interfaces. EXTRA CONCEPT OF METHOD OVERRIDING: ------------------------------------------------------------------------ Whenever methods parent has by default available to the child through inheritance sometimes child class may not satisfy with the parent method implementation. Then the child class is allow to redefine that method based on its own requirement. This process is called overriding. The parent class method is overridden is called overridden method. The child class method which is overriding is called overriding method.
3rd May 2019, 1:06 PM
Rajan Singla
Rajan Singla - avatar