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
Can any one give an example (Source Code) on virtual function implemetation in Java?
smal talk is pure object oriented or not?
is it acceptable if we declare multiple exceptions in same overridden method.
i want to improve my english vocab for racking campus written exam plz tell me best book for prepration......
code for connection from windows forms to sql server
in IT trend mantis meant what? how to know mantis in IT trends? detail description about mantis?
how to check single or double byte in struts
How to merge Action Form with Dyna Action Form in Struts.
In loading programs into memory, what is the difference between load-time dynamic linking and run-time dynamic linking?
What are the Short cut Keys of Tally ERP?
what is meaning of MDM in sap?let me know that meaning
Hello Experts, What is the difference between move and move corresponding exactly? please post me asap
Can we write a method in JSP.If so how?
I HAVE DONE TESTING TOOLS COURSE,NOW I AM FRESHER,I AM NOT GETTING ANY CALLS,I WANT TO DO THE PROJECT ,WHERE I HAVE TO MEET TO DO THE PROJECT,I AM GOING WITH FAKE EXPERIENCE,SO WHAT I HAVE TO DO.