Pass two ints as parameter and return the sum of numbers.

Test cases:

Test cases Expected Result
sum(10,12) 22 OK
sum(1,2) 3 OK
sum(2147483647,1) 2147483648 OK

Java solution:

public class Sum {
	public static void main(String[] args) {
		Sum.sum(10, 12);
		Sum.sum(1, 2);
		Sum.sum(2147483647, 1);
	public static long sum(int a,int b){
		return (long)a + b;

Javascript solution:

const sum = (a, b) => {
    return a + b;

console.log(sum(10, 12)); //22
console.log(sum(1, 2)); //3
console.log(sum(2147483647,1)); //2147483648


About the author

Bushan Sirgur

Hey guys, I am Bushan Sirgur from Banglore, India. Currently, I am working as an Associate project in an IT company.

View all posts

Leave a Reply

Your email address will not be published. Required fields are marked *