What do you meant by Runtime Polymorphism?
Answer Posted / 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 View All Answers
what is the system development cycle
Difference between HTML and DHTML?
hi i am jyoti i have done sap training in sd and master degree in economics have 2 year exp as enduser in (gdms)and 1 year as sd consultant.as contract basis now what i can do for getting job in it industry
what is the basic and unique feature of dotnet
MOV.CB 007H,ADCON1 MOVE.CT 001H,_OPTION_REG_7 MOV.CB 007H,CMCON
Hi guyes, I have cleared 2 technical rounds with cts for liferay and java techonologies, i have client round next week, please tell me how to prepare for this what questions i should be ready to face?
< DL Compact > tag is used for
through which algorithm does the garbage collector works? how the garbage collector will understand that the object will going to be deleted?
What is SOLID Principle in Programming Language?
what is adodb??y it is used for connection of V.B and access??what is ado?dao?
how to generate dsnless connectivity in j2ee
how to study PHP my own? i reffered many sites.. but as being a fresher i couldnt follow those... which site will be the best one?
Describe the difference between Interface-oriented, Object-oriented and Aspect-oriented programming
hai i am mca 2009 fresher.please tell me which certification helps me to get an IT job faster which institute is good in hyderabad.please mail me to prasanna.1856@rediff.com
i want to improve my english vocab for racking campus written exam plz tell me best book for prepration......