The following program is Overloading or Overriding?
public class PolymorphismEx {
public int sampleMethod(int a) {
return a;
}
public String sampleMethod(int a) {
return "Is it Overloading or Overriding???";
}
}
Answer Posted / hemanth
Its Neither Overloading nor overriding, Because for Overloading there should some Variation in argument list and for overriding the return type(if Primitive) should be same.
int method(int a)
{
}
String method(int a)
{
}
arguments should be different for overloading
return type should be same(if primitive) for overriding
so its improper which results in compile time error.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is identifier in java?
What are the uses of synchronized keyword?
What is the locale class in java programming?
Explain the difference between map and flatmap stream operation?
These static constructors are correct ? class A { statc intA() { } static A(int x,int y) { } static A(int x) { } }
Is a boolean variable?
What is the difference between overriding & overloading?
How do you do exponents in java?
explain different ways of using thread? : Java thread
What is gc()?
What is the output of the below java program?
What is the use of optional ?
Can we use static class instead of singleton?
What does the string method compareto () do?
How do you escape in java?