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...

Why Over riding is Run Time Polymorphism?

Answer Posted / anjani kumar jha

It is very diffcult for compiler to know which version of
the method called(superclass or subclass).

Hence to identify which version of method is called java
used run-time polymorphism(same copy used in both class)
where object type defined which version is called.
I am giving u one example............

class A
{
public void sum() //this is method which we will override
{
//some operation here//
}
}
class B extends A
{
public void sum() //over-riden method,see both method
r //same
{
//some operation here//
}
public static void main(String as[])
{
A a=new B() //RUN TIME POLYMORFISM
a.sum()//Since a is a object type of class B SO class B sum
method will be called................................
}
}
//I think uy doubt will be clear
}

Thanks and Regards
Anjani Kumar Jha
CDAC
9623154095

Is This Answer Correct ?    15 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain method overloading?

998


How many return statement are allowed in a function?

918


Are functions objects in java?

1058


How does multithreading take place on a computer with a single cpu in java programming?

994


placement papaers of spring computing technology

1388


What is the function of java?

985


Is Constructor possible in abstract class in java ?

1036


can I implement my own start() method? : Java thread

974


What is the map interface in java programming?

1001


Why set do not allow duplicates in java?

1069


What are the java ide’s?

1018


Why is string buffer better than string ?

1092


What is tostring () method?

998


why are there separate wait and sleep methods? : Java thread

1007


Why spring singleton is not thread safe?

986