Thursday, May 3, 2018

Output of the program [method overloading-iii]

Problem statement: Output of the method overloading program !
  1. class MethodOverload {}

  2. class MethodOverloadExe2 {
  3. public void run(Object o) {
  4. System.out.println("object");
  5. }
  6. public void run(String o) {
  7. System.out.println("string");
  8. }
  9. public void run(MethodOverload o) {
  10. System.out.println("user data type");
  11. }
  12. }
  13. public class OverloadingExe2 {
  14. public static void main(String[] args) {
  15. MethodOverloadExe2 m = new MethodOverloadExe2();
  16. m.run(null);
  17. }
  18. }
Output:
The method run(Object) is ambiguous for the type MethodOverloadExe2

No comments:

Post a Comment

Blueprint for self-improvement

To learn faster: Make the process fun To understand yourself : Write To understand the world better : Read To build deeper connection : Lis...