In case of overloading in java, it doesn't matter what is the return type of the method. What matters is the name of the method should be same, and their signatures should be different. But in case of overriding even there return types must match.
Which of the following is a legal return type of a method overloading the following
method:
public void add(int a) {…}
A. void
B. int
C. Can be anything
Select the most appropriate answer.(Answer you know is C)
method:
A. the overriding method must return voidpublic void add(int a) {…}
B. the overriding method must return int
C. the overriding method can return whatever it likes
Select the most appropriate answer.(answer you know is A)
No comments:
Post a Comment