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

how to stop execution of step 3 in a job mainframe

0 Answers  


Why we use NEW operator when we create Object,While in C++ we donot ?

1 Answers  


In loading programs into memory, what is the difference between load-time dynamic linking and run-time dynamic linking?

0 Answers  


will it allow to add same value in HashMap class.

0 Answers  


73. How can you set the status and title for a modal dialog box? a) In the attributes of the corresponding screen. b) Before the corresp. call screen statement. c) In a PBO module of the corresponding screen. d) In the PAI module of the corresponding screen.

1 Answers  






What are the Advantages of HashMap over Vector?

1 Answers  


how to display xisheet in list box in c# .net

0 Answers  


what are wrapper classes

2 Answers  


What does this useful command line do? tasklist /m "mscor*"

1 Answers  


What is the client concept in SAP? What is the meaning of client independent?

3 Answers  


What ports must be open for DCOM over a firewall? What is the purpose of Port 135?

1 Answers  


I'm new to ABAP. What is Module pool in SAP?

0 Answers   TCS,


Categories