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 difference between static and final?
Explain an algorithm to find depth of a binary tree.
Explain 5 io best practices?
What type of variable is gender?
What is the difference between sleep and wait in java?
What does string [] args mean?
What is an exception in java?
What is java console application?
Write a program to print the pattern given below
What is the purpose of java?
Can we have two methods in a class with the same name?
What are the various access specifiers in java?
What are basic keywords?
What is the full form of jpeg?
What is anagram of a string?