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


some one give d clear explanation for polymorphism

Answers were Sorted based on User's Feedback



some one give d clear explanation for polymorphism..

Answer / anjani kumar jha

Java supports two types of polymorphism
1)compile time
2)Run time

1)Compile:---overloading is the best example of compile-
time polymorphism.
Look at this example:----

class NewClass {

public void aSum()
{
System.out.println("hi.......");
}
// NewClass nc1=new InheritClass();
// NewClass nc=new NewClass();
}
class InheritClass extends NewClass
{
@Override
public void aSum()
{
System.out.println("over-riden......");
}
public static void main(String as[])
{
NewClass nc=new NewClass();
NewClass nc1=new InheritClass();

nc.aSum();.......compile time polymorphism
reference type determine which method to be invoke
//nc1.aSum();
}




2)Run time:Over-ridding is the example of run time
polymorphism........

look at example----
class NewClass {

public void aSum()
{
System.out.println("hi.......");
}
// NewClass nc1=new InheritClass();
// NewClass nc=new NewClass();
}
class InheritClass extends NewClass
{
@Override
public void aSum()
{
System.out.println("over-riden......");
}
public static void main(String as[])
{
NewClass nc=new NewClass();
NewClass nc1=new InheritClass();

// nc.aSum();
nc1.aSum(); //object type determine which method
shuold call
//run the example u will get idea about that
}
}
}

Is This Answer Correct ?    5 Yes 1 No

some one give d clear explanation for polymorphism..

Answer / ullu ka patha

polymorphism is an OOP's concept by virtue of which
different classes are able to use same attributes,functions
and modules with same names.

Is This Answer Correct ?    1 Yes 0 No

some one give d clear explanation for polymorphism..

Answer / jananekrishnan

polymorphism means ability to take more than one form

simply,
polymorphism means
"write once,
run any environment,anytime"

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More OOPS Interview Questions

How do you define a class in oop?

0 Answers  


Explain polymorphism? What r the types of polymorphism? pls give examples?

4 Answers   HCL,


suppose A is a base class and B is the derved class. Both have a method foo which is defined as a virtual method in the base class. You have a pointer of classs B and you typecast it to A. Now when you call pointer->foo, which method gets called? The next part of the question is, how does the compiler know which method to call?

3 Answers   EA Electronic Arts,


What is the difference between pass by value,pass by pointer,pass by reference in the catch block in the exception handling in c++

1 Answers   TCS,


What are different oops concepts?

0 Answers  


What is polymorphism in oops with example?

0 Answers  


4. What do you mean by a prototype? Define analysis prototype

1 Answers  


Explain the concept of abstracion and encapsulation with one example. What is the difference between them?

3 Answers   PCS,


what is overloading

3 Answers   MindCracker,


What is class and object in oops?

0 Answers  


what is the use of mutable key word

3 Answers   HCL,


What is the difference between and interface and an abstract class ?

4 Answers   IBM, Infosys, Ness Technologies,


Categories