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

What is difference between static and final?

561


Explain an algorithm to find depth of a binary tree.

554


Explain 5 io best practices?

599


What type of variable is gender?

552


What is the difference between sleep and wait in java?

517






What does string [] args mean?

543


What is an exception in java?

648


What is java console application?

563


Write a program to print the pattern given below

502


What is the purpose of java?

561


Can we have two methods in a class with the same name?

588


What are the various access specifiers in java?

571


What are basic keywords?

560


What is the full form of jpeg?

525


What is anagram of a string?

523