9. Write a program to perform basic arithmetic operations through methods by passing actual arguments from calling
statement
Answers
Answered by
1
import java.io.*;
class Main
{
// create a method
public int addNumbers(int a, int b)
{
int sum = a + b;
// return value
return sum;
}
public static void main(String[] args)
{
int num1 = 25;
int num2 = 15;
// create an object of Main
Main obj = new Main();
// calling method
int result = obj.addNumbers(num1, num2);
System.out.println("Sum is: " + result);
}
}
Similar questions
Accountancy,
2 months ago
India Languages,
4 months ago
Math,
4 months ago
English,
10 months ago
Political Science,
10 months ago