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
Wha is the output from system.out.println(“hello”+null); ?
What are the four integer types supported by java?
Does importing a package imports its sub-packages as well in java?
Explain about exception propagation?
Is array size fixed in java?
Which methods cannot be overridden in java?
Is ++ operator thread-safe in java?
what is the major difference between linkedlist and arraylist in java?
What is byte [] in java?
Can a constructor be made final?
Write a program to search a number in the given list of numbers.
difference between byte stream class and character stream class?
Differentiate between the constructors and methods in java?
When do you get classcastexception?
Where are register variables stored?