What are the different types of polymorphism?

Showing Answers 1 - 49 of 49 Answers

capreatki

  • Jul 19th, 2005
 

two.. one is RUNTIME Polymorphism which includes virtual functions etc and another is COMPILE TIME Polymorphism which includes function overloading etc..

Amit Banerjee

  • Sep 1st, 2005
 

Two types of polymorphism: 
1. Static Polymorphism (Early binding) 
2. Dynamic Polymorphism (Late binding)

capreatki Wrote: two.. one is RUNTIME Polymorphism which includes virtual functions etc and another is COMPILE TIME Polymorphism which includes function overloading etc..

Can u give brief idea, how it is possible to implement compile time polymorphism(method overloading or operator overloading)... without creating object... How it is maintaining virtual tables....

  Was this answer useful?  Yes

Yashwant S pinge

  • Mar 27th, 2006
 

hello,There are two types of polymorphism as shown above.static polymorphism :-- operator oveloading and function overloading.dynamic plymorphism :- virtual functionality

  Was this answer useful?  Yes

sapam james

  • Nov 8th, 2006
 

Polymorphism is mainly divided into :

1) Run Time polymorphism: a) Virtual function

2) Compile Time Polymorphism : a) function overloading

                                           b) operator overloading

  Was this answer useful?  Yes

There are 2 types of Polymorphism
1. Compile time Polymorphism
2. Run Time Polymorphism
Compile time polymorphism is used for Function overloading
Runtime is used for implementing virtual functions,overriding etc.

knicholes

  • Oct 2nd, 2010
 

There are FOUR kinds of polymorphism

1.  Overloading  (Same function names, different parameter types.  This includes operator overloading and is done at compile time)

1.  Parametric polymorphism  (These are like templates in C++)  Compile time

3.  Subtype polymorphism (if a function has a parameter with a subtype, for example Car->Honda, f(Car), then function f will accept f(Honda) as well.)  Runtime

4.  Parameter coercion  (This is an implicit type conversion.  For example, a function might require a double/real/float, but will accept an int and will implicitly upcast the parameter)
Compile time

jimasp

  • Oct 22nd, 2010
 

knicholes answer is correct. I would also add that Overloading in this context is also known as "ad hoc polymorphism".

If you want to be picky, there are probably more specific types of polymorphism too, but they are best left to the academics (have a look at http://en.wikipedia.org/wiki/Type_polymorphism).

  Was this answer useful?  Yes

sai

  • Jul 13th, 2011
 

Hi! friends this Praveen From Hyderabad.
There are two types of polymorphism
1. Dynamic polymorphism(run time or dynamic binding): the polymorphism exhibited at run time is called dynamic polymorphism. this means when a method is bound to the method body at the time of running the program,dynamically.
Here the java compiler does not decide which method id called at compilation time, jvm decides which method is called at run time.
We can achieve Dynamic Polymorphism by using overloading and overriding on instance variables and concrete methods.
2. Static polymorphism(compile time or static binding): the polymorphism exhibited at compile time is called static polymorphism.
Here the java compiler decides which method id called at compilation time.
We can achieve static Polymorphism by using overloading and overriding on static methods.

Code
  1. // this is the method overloading concept example

  2. class Poly

  3. {

  4. void cal(int a,int b)

  5. {

  6. System.out.println(" Sum of two numbers : "+(a+b));

  7. }

  8. }

  9.  

  10. class Poly1 extends Poly

  11. {

  12. void cal(int a,int b)

  13. {

  14. System.out.println(" Product of two numbers : "+(a*b));

  15. }

  16. }

  17. class Demo1

  18. {

  19. public static void main(String args[])

  20. {

  21. Poly1 p1=new Poly1();

  22. p1.cal(10,20);

  23.  

  24. }

  25. }

  26.  

  Was this answer useful?  Yes

Anita

  • Aug 2nd, 2011
 

This program is for method overriding not for overloading

Code
  1. #

  2. class Poly

  3.  

  4. #

  5. {

  6.  

  7. #

  8. void cal(int a,int b)

  9.  

  10. #

  11. {

  12.  

  13. #

  14. System.out.println(" Sum of two numbers : "+(a+b));

  15.  

  16. #

  17. }

  18.  

  19. #

  20. }

  21.  

  22. #

  23.  

  24.  

  25. #

  26. class Poly1 extends Poly

  27.  

  28. #

  29. {

  30.  

  31. #

  32. void cal(int a,int b)

  33.  

  34. #

  35. {

  36.  

  37. #

  38. System.out.println(" Product of two numbers : "+(a*b));

  39.  

  40. #

  41. }

  42.  

  43. #

  44. }

  45.  

  46. #

  47. class Demo1

  48.  

  49. #

  50. {

  51.  

  52. #

  53. public static void main(String args[])

  54.  

  55. #

  56. {

  57.  

  58. #

  59. Poly1 p1=new Poly1();

  60.  

  61. #

  62. p1.cal(10,20);

  63.  

  64. #

  65.  

  66.  

  67. #

  68. }

  69.  

  70. #

  71. }

  Was this answer useful?  Yes

WF

  • Aug 29th, 2011
 

SNPs, RFLPs, STRs, VNTRs

  Was this answer useful?  Yes

nagtan3

  • Oct 24th, 2011
 

This is not overloading, but overriding !!!

Code
  1.  

  2. class Poly

  3. {

  4. void cal(int a,int b)

  5. {

  6. System.out.println(" Sum of two numbers : "+(a+b));

  7. }

  8. }

  9.  

  10. class Poly1 extends Poly

  11. {

  12. void cal(int a,int b)

  13. {

  14. System.out.println(" Product of two numbers : "+(a*b));

  15. }

  16. }

  17. class Demo1

  18. {

  19. public static void main(String args[])

  20. {

  21. Poly1 p1=new Poly1();

  22. p1.cal(10,20);

  23.  

  24. }

  25. }

  Was this answer useful?  Yes

kaiza fadhili

  • Apr 23rd, 2012
 

* Compile time Polymorphism
* Run time Polymorphism

  Was this answer useful?  Yes

Akash Singhal

  • May 17th, 2012
 

Polymorphism means ability to take more than one form.

Overloading is an example of compile time polymorphism.(Because the function to call is decide at compile time)
Overriding an example of compile time polymorphism.(Because the function to call is decide at runtime)

Overloading:

Math math=Math();
math.add(10,20)
math.add(10,20,30)

Overriding:

superclassObject.add(10,10)
subclassObject.add(10,10)

Here in the case of Overriding the method which will call is decide will decide at the runtime.

  Was this answer useful?  Yes

sandeep

  • Sep 16th, 2012
 

1. Static Polymorphism (Early binding)
2. Dynamic Polymorphism (Late binding)

  Was this answer useful?  Yes

kutty

  • Sep 24th, 2012
 

how to write a simple java programs for overloading & overriding

  Was this answer useful?  Yes

Have Fun

  • Dec 28th, 2012
 

Two:
Ad-hoc polymorphism and universal polymorphism

  Was this answer useful?  Yes

tux

  • Jul 4th, 2015
 

There are two types controlled and uncontrolled polymorphism.
Overloading wont belong to type of polymorphism
Overriding is tool to implement polymorphism.

  Was this answer useful?  Yes

syedafarzana

  • Mar 31st, 2016
 

Compile time Polymorphysim and Runtime Polymorphism

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions