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
Explain the purpose of garbage collection in Java?
What value is a variable of the string type automatically initialized?
How big is a gigabyte?
What is methods in java?
What is a instance variable in java?
What is java in simple terms?
What is the access scope of a protected method?
Can java run on google chrome?
what are the high-level thread states? : Java thread
Why volatile is used in java?
Explain 5 features introduced in jdk 1.7?
Can static method access instance variables ?
What is difference between synchronize and concurrent collection in java?
Is a string literal?
What is the use of jtable?