What do you meant by Runtime Polymorphism?

Answers were Sorted based on User's Feedback



What do you meant by Runtime Polymorphism?..

Answer / pankajbisane

Runtime polymorphisms means the code is called at run time
according to need or given conditions.

suppose there r two methods namely Add() one in super class
and other is in sub class.both have the same name and same
parameters.

so we have to choose that which method from them should
called at run time i.e. of super class or of sub class.

It can be achieved through the use of virtual functions.

Is This Answer Correct ?    1 Yes 0 No

What do you meant by Runtime Polymorphism?..

Answer / swe

In runtime polymorphism ... the code is called at run time according to need or given conditions.

suppose there r two methods namely Add() one in super class and other is in sub class.both have the same name and same parameters.

so we have to choose that which method from them shld called at run time i.e. of super class or of sub class.by polymorphism we do that.

ex:-

class A

{

int add(){//code of the method}

//some other code

}

class B extends A

{

int add(){//code of the method}

//some other code

}

class AB

{

public static void main(String s[])

{

A ob1;

ob1 new A();

int i ob1.add();//will call the method of super class.

ob1 new B();// sub class's reference can be assigned to super class address but not vice versa.to do that we have to type cast the reference of the sub class in reference of the super class.

int j ob1.add();//will call the method of sub class

}

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More Programming Languages AllOther Interview Questions

what is throws keyword

1 Answers   IBM,


what is client server & server? What r types of Joins? explsin it! which types of indexex in sql server? what is triggers?

0 Answers  


where is available in this mantis toturials?

0 Answers  


Hello Experts, What is the difference between move and move corresponding exactly? please post me asap

0 Answers  


Full from of MP3?

2 Answers  






Where do we need Operator overloading?

0 Answers   BirlaSoft,


why we use mantis? what u mean mantis in IT trends? addvantages of mantis?

0 Answers   HCL, Sacred Heart College,


What is Negative testing?

0 Answers  


how MATLSB software suitable for electrical branch? which tools are useful??

1 Answers  


Fortran cannot have value by reference True or False?

2 Answers   Geometric Software,


What is Boxing?

3 Answers  


Write a program to find whether a given number is prime or not.

0 Answers   Syntel, Visa,


Categories