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
State one difference between a template class and class template.
What is the SimpleTimeZone class?
What is multi-catch block in java?
Explain the difference between collection api and stream api in java8?
What do you mean by byte code?
Explain reverse a linked list recursive java solution?
What is a Hash Table? What are the advantages of using a hash table?
What's the difference between int and integer in java?
What state does a thread enter when it terminates its processing in java programming?
How do you create a null object?
what is the messsage u r going to get from an objectoriented programing?
What is static import?
What is a double vs float?
What is public static void main?
What is an array length?