# What is the result?

Given:

What is the result?
A. int sum is 30 float sum is 30.0
B. int sum is 30 double sum is 30.0
C. integer sum is 30 double sum is 30.0
D. integer sum is 30 float sum is 30.0

## 6 thoughts on “What is the result?”

1. Anand Mohan D says:

int sum is 30
double sum is 30.0

2. Andrew says:

B:
# javac SumTest.java
# java SumTest
int sum is 30
double sum is 30.0

3. Sam Ammatouri says:

Compiler will select the most accurate parameter definition. It selected the “int” rather than the “Integer” because the supplied parameters are closer to “int” of “Integer”. As for the decimal point number, they are double instead of float, because there is not “f” post-fix.

4. Sergi says:

public class Test {
public static void doSum(Integer x, Integer y){
System.out.println(“Integer sum is ” + (x + y));
}

public static void doSum(double x, double y){
System.out.println(“double sum is ” + (x + y));
}

public static void doSum(float x, float y){
System.out.println(“float sum is ” + (x + y));
}

public static void doSum(int x, int y){
System.out.println(“int sum is ” + (x + y));
}

public static void main(String[] args) {
doSum(10, 20);
doSum(10.0, 20.0);
}
}
//Result
//int sum is 30
//double sum is 30.0

5. Suleyman Alptekin says:

B