What will be the result of the following code execution?

public class StartClass {
    public static void main(String[] args) {
        Double d1 = 1d;
        Double d2 = 1d;
        System.out.println(d1 == d2);
    }
}
Explanation
Every Double object (starts with upper case) is a different instance and has it's own address in a memory. As operator == compares object references, and not values, Result will be false.

@holladj04 It should be right ;)

2017 May 17, 11:44:38 PM

Correct the answer please.

2016 Nov 11, 4:12:06 AM

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Продолжайте изучать
тесты по Java
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты