JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
Developing a multiple method with same method name but different method argument is known as method overloading. here the argument should change either in no. of argument, sequence of argument or different argument.
method overloading applies to both sataic and non static method
method can be overloaded in same class or diferent class(sub class)
*/
class A{
void abc(){
System.out.println("Method with no argument");
}
void abc(int a){
System.out.println("Method with int argument. Value of passed argument is "+a);
}
void abc(String a){
System.out.println("Method with String argument. Vlaue of passed argument is "+a);
}
void abc(String a, int b){
System.out.println("Method with String and int argument. Values of String argument is "+a +" and int argument is "+b);
}
void abc(int a, String b){
System.out.println("Method with String and int argument. Values of int argument is "+a +" and String argument is "+b);
}
}
public class Program
{
public static void main(String[] args) {
A a1= new A();
a1.abc();
a1.abc(10);
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run