Problem statement: Output of the method overloading program !
- class MethodOverload {}
- class MethodOverloadExe2 {
- public void run(Object o) {
- System.out.println("object");
- }
- public void run(String o) {
- System.out.println("string");
- }
- public void run(MethodOverload o) {
- System.out.println("user data type");
- }
- }
- public class OverloadingExe2 {
- public static void main(String[] args) {
- MethodOverloadExe2 m = new MethodOverloadExe2();
- m.run(null);
- }
- }
Output:
The method run(Object) is ambiguous for the type MethodOverloadExe2
No comments:
Post a Comment