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 is run time polymorphism

Answers were Sorted based on User's Feedback



what is run time polymorphism..

Answer / vijayakumar chinnasamy

In Java Method overriding is the runtime or late binding
polymorphism.

class object is determine which class method is invoked.

ex:

class A {
protected void display(){ }

}

class B extends A {

protected void display(){ }

}

class MainClass {
public static void main(String arg[]){

A objA=null;
objA=new B();
objA.display(); // it invoke the Class B's display()

objA=new A();
objA.display(); // it invoke the Class A's display()

}

}

Note: the class's object only determine which method to call.

Is This Answer Correct ?    2 Yes 0 No

what is run time polymorphism..

Answer / durgasri

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 0 No

what is run time polymorphism..

Answer / shiry

In C++ ;
if i have 2 clases
class A {

int x();
}
class B : public A {

int x();
}
void main(){

A* a = new B() ;
a.x(); // it will call the method of the super class A
// not B but in java it will call the method in the
// child B why ??

}

Is This Answer Correct ?    0 Yes 0 No

what is run time polymorphism..

Answer / venu

Runtime polymorphism is nothing but, JVM identifies the behavior (Method) invocation of the reference based on the reference pointing to the Object. Runtime Polymorphism is experimented by an example of Method Overriding.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

What is externalizable?

0 Answers  


Can we access instance variables within static methods ?

0 Answers  


What is number data type?

0 Answers  


What is the base class of all exception classes in java?

0 Answers  


What is a top level class in java?

0 Answers  


Differentiate between overriding and overloading cases?

0 Answers   Amdocs,


Is 0 a real number?

0 Answers  


What is the diff. b/w Interfaces & Abstract class?

6 Answers   Ericsson,


List any five features of java?

0 Answers  


Why is the main method static?

0 Answers  


Name the package that most of the AWT events that supports event-delegation model are defined?

2 Answers  


Explain java coding standards for classes or java coding conventions for classes?

0 Answers  


Categories