What do you meant by Runtime Polymorphism?
Answers were Sorted based on User's Feedback
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 |
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 |
Urgent Openings for Java and .NET ( India, Singapore, Australia, Japan)
Write a program to implement BFS/ DFS routine in a connected graph
what is the BAM? where we can use it in BizTalk server?
needs examples for black box testing and white box testing
Need guidewire related Documents(Interview Question/Tips/Best Practice/Dumps)
What is the difference between windows 98/2000/XP Operating Systems?
16 Answers CMS, Siemens, TCS,
How to set fixed width in particular <td> in html? if i type more character in this <td> it will not push near <td>. this is my question. can u tell me the answer...
what will be the model paper for the post of assistant programmer in delhi high court
what is the difference between primary key and unique key?
what is d main diff between the java and .net framework
Can anyone send me NIC question papers alongwith answers on nidhi1485@yahoo.co.in? Urgently needed.. Thanks in advance
In java without use of main() how to execute the program