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


Please Help Members By Posting Answers For Below Questions

How to know we are in home page of a web application using QTP

2173


What is the meaning of client-server application. The purpose of Client-Server Application. with description.

1861


What is the entry point function of a DLL?

785


please any one pass file aid,xpeditor and endeavor tools

2084


hii I inntrested abt scjp certification but i dont knw abt scjp plz send details abt scjp exam and syllabus.

1596






what are the differences between CONS, LIST, and APPEND

4972


Plz sent me in .net 2.0 interview Question & answers?

1871


Please describe an example where you used object orientation in one of your programs.

1667


how to fin top two miximum values in sql? not 2nd both max value of 1st and 2nd both have to find out

1667


What is BASIS

1878


How many forms can you create in a Visual Basic 6 Standard EXE project? Is there any limit on that?

1714


what are the missinschema properties and should we pass primary key in select command

1621


You are given some denominations of coins in an array (int denom[])and infinite supply of all of them. Given an amount (int amount), find the minimum number of coins required to get the exact amount. What is the method called?

812


Definition of Singleton Class? what is the Purpose of it? what is the advantage?

1814


Hai, My name is nisha.I have NIC exam.If anybody Knows NIC previous paper pattern pls send me to nishanairp@gmail.com

1923