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 are aggregate functions explain with examples?
why are there separate wait and sleep methods? : Java thread
What is the difference between math floor and math round?
What is bom encoding?
State one difference between a template class and class template.
Can a constructor call the constructor of parent class?
Can you sort a list in java?
What about main() method in java ?
How does arraylist size increase in java?
What is use of arraylist in java?
What is the java project architecture?
Which non-unicode letter characters may be used as the first character of an identifier?
What is an enumeration?
What is a nullable field?
What is the use of coding?