PARAMETERS METHODS IN JAVA
Parameters are specified after the method name, inside the parentheses. You can add as many parameters as you want, just separate them with a comma.
The following example has a method that takes a String called fname as parameter. When the method is called, we pass along a first name, which is used inside the method to print the full name
https://www.w3schools.com/java/java_methods_param.asp
MY JAVA PORGRAM IN PARAMETERS:**
class Cal{
//int a;
//int b;
//int c;
public int AddMethod(int a,int b,int c){
int sum=a+b+c;
return sum;
}
public int AddMethod1(int a,int b){
int sum1=a+b;
return sum1;
}
public int SubMethod(int a,int b,int c){
int sub=a-b-c;
return sub;
}
public int SubMethod1(int a,int b){
int sub1=a-b;
return sub1;
}
public int MutMethod(int a,int b,int c){
int mut=a*b*c;
return mut;
}
public int MutMethod1(int a,int b){
int mut1=a*b;
return mut1;
}
public int DivMethod(int a,int b,int c){
int div=a/b/c;
return div;
}
public int DivMethod1(int a,int b){
int div1=a/b;
return div1;
}
public static void main(String args[]){
Cal object=new Cal();
System.out.println("The addtion three number:"+ object.AddMethod(10, 20, 30));
System.out.println("The addtion two number:"+ object.AddMethod1(10, 20));
System.out.println("The Subtraction three number:"+ object.SubMethod(10, 30, 60));
System.out.println("The Subtraction two number:"+ object.SubMethod1(10, 50));
System.out.println("The Mulipucation three number:"+ object.MutMethod(10, 50,30));
System.out.println("The Mulipucation two number:"+ object.MutMethod1(10, 50));
System.out.println("The Division three number:"+ object.DivMethod(10, 50, 60));
System.out.println("The Division two number:"+ object.DivMethod1(10, 50));
}
}
MY ERRORS AND MY OUTPUT:
Top comments (0)