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
Hi all... I had completed MSC(Computer) and had join the construction company based on sap.they want me to work on abap.but software company is totally different from construction company and they want me 2 grasp it as fast i can.i am finding it difficult.what should i do??????
MOV.CB 007H,ADCON1 MOVE.CT 001H,_OPTION_REG_7 MOV.CB 007H,CMCON
Write a program to create a process in UNIX
Display names and numbers of employees who have 5 years or more experience and salary less than Rs.15000 using array of structures (name, number, experience and salary)
A good website has the following conditions It should be interactive. It should contain at least 20 images. Title cannot be null and should contain at least 10 letters other than spaces and hyphen (-). The keywords should contain atleast three among the following list : "design", "Graphics", "lovely", "beautiful", "amazing" and "mesmerising" Write a method: boolean isGoodWebsite(boolean isInteractive, int numOfImages, String title,String keywords[]) isInteractive whether the site is interactive or not numOfImages Number of images on the website title Title of the website keywords Array of keywords in the website.
what is the difference between rename and label
What are two of your strengths that you will bring to our QA/testing team?
Explain polymorphism. Provide an example.
Given: coordinates of rectangle-> left bottom and right top points. the rectangles create a hole.Find the maximum area of the hole. eg. 4 rectangles create a hole in between. find its area.
What are the tasks performed by a Team Lead
can u send some model papers how computer awareness questions are asked in goverment jobs(oriental insurance)to my mail id me.priyankapadma@rediff.com
what is integration testing in real time applications?
what is the difference between an OS(operating system) and Framework?
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?
what is meant by life cycle of a business