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 meant by tab pans?
What are the main differences between the java platform and other platforms?
How infinite loop is declared?
What is module in oop?
Which container method is used to cause a container to be laid out and redisplayed in java programming?
What is strings in java?
What is final method in java?
What is a pattern what is an anti pattern?
Write java program to reverse string without using api?
What is a finally block?
What is the exact difference in between Unicast and Multicast object? Where will it be used?
Tell us something about an iterator.
Explain about static nested classes in java?
Are strings immutable in java?
Why are lists ordered in java?