Method Overloading

package method_overloading;
public class Method_Overloading {
void A() {
System.out.println("PQR, a method with no parameter ");
}
void A(int a) {
System.out.println("XYZ, a method with parameter :" + a);
}
public static void main(String[] args) {
Method_Overloading ob = new Method_Overloading(); //in meth_ovld 2 or more mthod has same name in a class with different argument
ob.A();
ob.A(5);
}
}
OUTPUT
PQR, a method with no parameter
XYZ, a method with parameter :5









No comments:

Post a Comment