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

Write A Program to find the ambiguities in Multiple Inheritance? How are they resolved.(Virtual Functions)

0 Answers   Accenture,


//what is wrong with the programme?? #include<iostream.h> template <class first> class dd { first i; public: void set(); void print(); }; void dd< first>:: set() { cin>>i; } void dd< first>::print() { cout<<"\n"<<i; } void main() { dd <char>g; g.set(); g.print(); }

1 Answers  


what is the difference between class and object?

9 Answers  


What is the renewal class?

0 Answers   Ebix, IBM,


Can abstract class have normal methods?

0 Answers  






what is ns string? what is ns array?

1 Answers  


What is design patterns in C++?

2 Answers   Persistent,


program for insertion ,deletion,sorting in double link list

0 Answers  


How to execute business logic for only once ..?even though user clicks submit button multiple times by mistake..? (i disabled JavaScript)

1 Answers  


what is multithreading in c++ , what is difference between multithreading and singlethreading.

4 Answers  


what is pointers

7 Answers   Exilant,


inheritence with example

1 Answers  


Categories