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

In JCl , we have COND parameter.This holds comparison code and condition.It also has only and even parameters. ex: COND((4,GE),EVEN).what the comma mean here. is that 'and' or 'or'.

0 Answers   L&T,


CPU - abbrevation

2 Answers   Mascot,


Given an array of size n. It contains numbers in the range 1 to n. Each number is present at least once except for 2 numbers. Find the missing numbers.

0 Answers   Amazon,


1. How many jobs can we write in a single file? 2. How many maximum members can exist in a single partition data set(pds) in jcl?

0 Answers   Steria,


how to run servlets in eclipse 3.3.2....if we choose file->new->servlet then after that it is showing javax.servlet.* ...cannot be resolved.......to avoid this error any external jar file is to be added? please help me regarding this issue........thank u

2 Answers   IBM,






cgi stands for

2 Answers   CGI,


When we have two versions of the dot net installed how does the compiler know which version of DLL it has to select to an application.

0 Answers   Tesco,


what are the advantages of sap on other software ?

0 Answers  


Wrtite a JCL for sorting a file with start from 36 postion lenth 9 excluding a num eq to 98768. for 3 marks mainframe

0 Answers  


what is meaning of MDM in sap?let me know that meaning

0 Answers  


how do i add a column dynamically in a table by using java application?

0 Answers  


what are all the validation we need to perform in data stage?

0 Answers  


Categories