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

What is a friend function & its advantage?

2 Answers   TCS,


what is virtual function in c++

6 Answers  


What is encapsulation c#?

0 Answers  


Polymorphism with an example?

8 Answers   Accenture, emc2,


What is destructor example?

0 Answers  






What is a function in oop?

0 Answers  


who is the founder of c++?

15 Answers   Hexaware, ONGC,


i ahve v low % in 12th n BSC which is aroun 50 coz science was imposed on me......nw m doin MCA n my aggregate in above 74%,what shud i say if asked about low previous percentage??????

4 Answers  


Write an operator overloading program to Overload ‘>’ operator so as to find greater among two instances of the class.

1 Answers  


What does oop mean in snapchat?

0 Answers  


How do you achieve runtime polymorphism?

0 Answers  


What is multiple inheritance? Give Example

6 Answers   Mind Tree,


Categories