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


Please Help Members By Posting Answers For Below Questions

State one difference between a template class and class template.

630


What is the SimpleTimeZone class?

1807


What is multi-catch block in java?

630


Explain the difference between collection api and stream api in java8?

521


What do you mean by byte code?

525






Explain reverse a linked list recursive java solution?

541


What is a Hash Table? What are the advantages of using a hash table?

612


What's the difference between int and integer in java?

552


What state does a thread enter when it terminates its processing in java programming?

587


How do you create a null object?

522


what is the messsage u r going to get from an objectoriented programing?

1619


What is static import?

611


What is a double vs float?

545


What is public static void main?

583


What is an array length?

510