Program to Add Two Numbers in Java
Below is the implementation of adding two Numbers are mentioned below:
Java
// Java Program to implement // Direct Addition to Add two Numbers import java.io.*; // Driver Class class GFG { public static int sum( int num1, int num2) { return num1+num2; } // main function public static void main(String[] args) { GFG ob = new GFG(); int res = ob.sum( 28 , 49 ); System.out.println(res); } } |
Output
77
Java Program to Add Two Numbers
Given two integers num1 and num2, the task is to find the sum of the given two numbers in Java.
Example of Addition of Two Numbers
Input: A = 5, B = 6
Output: sum = 11Input: A = 4, B = 11
Output: sum = 15