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

Download Printable PDF. VALID exam to help you PASS.

6 thoughts on “What is the result?

  1. Answer B:

    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.

  2. Answer is B

    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

Leave a Reply

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


The reCAPTCHA verification period has expired. Please reload the page.