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

which is best institute to learn c,c++ in ameerpet hyderabad

1 Answers  


What is the example of polymorphism?

0 Answers  


WHEN A COPY CONSTER IS CALL ?

4 Answers  


What are the three main types of variables?

0 Answers  


can main method be overloaded...??? How..????

2 Answers   Satyam,


What does I oop mean?

0 Answers  


which structured data type is not used in c++? 1.union 2.structure 3.string 4.boolean

2 Answers   HCL, Wipro,


#include <string.h> #include <stdio.h> #include <stdlib.h> #include <conio.h> void select(char *items, int count); int main(void) { char s[255]; printf("Enter a string:"); gets(s); select(s, strlen(s)); printf("The sorted string is: %s.\n", s); getch(); return 0; } void select(char *items, int count) { register int a, b, c; int exchange; char t; for(a = 0; a < count-1; ++a) { exchange = 0; c = a; t = items[ a ]; for(b = a + 1; b < count; ++b) { if(items[ b ] < t) { c = b; t = items[ b ]; exchange = 1; } } if(exchange) { items[ c ] = items[ a ]; items[ a ] = t; } } } design an algorithm for Selection Sort

0 Answers  


What is the diamond problem in inheritance?

0 Answers  


What is the difference between const int *ptr and int const *ptr???

2 Answers  


What is the difference between C++ and java?

6 Answers   Atos Origin,


write a program for function overloading?

14 Answers   HCL, InfoCity, TATA,


Categories