n java, method overloading is not possible by changing the return type of the method because there may occur ambiguity.here is an example which state how ambiguity might occur:
here how java determine which method to call
class Calculation3{ int sum(int a,int b){System.out.println(a+b);} double sum(int a,int b){System.out.println(a+b);} public static void main(String args[]){ Calculation3 obj=new Calculation3(); int result=obj.sum(20,20); //Compile Time Error } }
Liked By
Write Answer
Why method overloading is not possible by changing the return type in java?
Join MindStick Community
You have need login or register for voting of answers or question.
Anonymous User
30-Mar-2015