Computer Science, asked by gowrivinod1645, 1 year ago

How multiple arithmetic operation performed in a java program?

Answers

Answered by Anonymous
5
hii dear!!

here ur answer!!

▪▪public class my way example for u:-
{
int add(int num1, int num2)
{
return num1+num2;
}
int add(int num1, int num2, int num3)
{
return num1+num2+num3;
}
int add(int num1, int num2, int num3, int num4)
{
return num1+num2+num3+num4;
}
public static void main(String[] args)
{
Java Example obj = new Java Example();
//This will call the first add method
System.out.println("Sum of two numbers: "+obj.add(10, 20));
//This will call second add method
System.out.println("Sum of three numbers: "+obj.add(10, 20, 30));
//This will call third add method
System.out.println("Sum of four numbers: "+obj.add(1, 2, 3, 4));
}
}

☆☆Output:

Sum of two numbers: 30
Sum of three numbers: 60
Sum of four numbers: 10

♡hope help u plz mark brainlist!!!
#HACKER#
Similar questions