Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

What is SOLID Principle in Programming Language?

1133


Given an array of size n+1 which contains all the numbers from 1 to n.Find the number which is repeated in O(n) time.How do you proceed with the same with floating numbers from 0 to 1 instead of 1 to n?

999


4. What is the need of START 0? Instead if can we use any other numeric? If we use what will happen?

2298


How does the type system works when there is interoperability between a COM and .Net, i mean what exactly happens there

2005


HOW TO FIND NUMBER OF TWOS IN N!(N FACTORIAL)??

2207


what is the extension of SPDS Dynamic cluster tables?

2093


why we use mantis? what u mean mantis in IT trends? addvantages of mantis?

2159


when we use mantis? how learn mantis?

2115


My Qualification is MCA.My interview is on 5th may.They may ask q as------AS u r MCA...Why u r not tring anywhere else? What can be the ans?

1895


Write a program to find factorial of a number using functions

1640


what is session state?

1897


Find out the list of roles which gives access to GUI activities? thanks in advance

2088


Find out the roles which gives access to all tables in SAP? Thanks in advance.

1979


if 3 duplicate records, by keeping one original and one duplicate record, and how to delete remaining 2 duplicates in sql server 2008

2094


What is autocall macro and how to create autocall macro? what is the use of it?

1981