Telegram Group & Telegram Channel
🕕 Задача по Java: Что будет выведено?


public class Main {
public static void main(String[] args) {
Integer a = 127;
Integer b = 127;
Integer c = 128;
Integer d = 128;

System.out.println(a == b); // ?
System.out.println(c == d); // ?
}
}


Варианты:
A) true, true
B) true, false
C) false, true
D) false, false

Правильный ответ: B

Объяснение:
Java кэширует объекты Integer в диапазоне -128 ... 127.
a == b — то же значение и тот же объект.
c == d — разные объекты вне кэша. Используй .equals() для сравнения!



tg-me.com/java_quizes/217
Create:
Last Update:

🕕 Задача по Java: Что будет выведено?


public class Main {
public static void main(String[] args) {
Integer a = 127;
Integer b = 127;
Integer c = 128;
Integer d = 128;

System.out.println(a == b); // ?
System.out.println(c == d); // ?
}
}


Варианты:
A) true, true
B) true, false
C) false, true
D) false, false

Правильный ответ: B

Объяснение:
Java кэширует объекты Integer в диапазоне -128 ... 127.
a == b — то же значение и тот же объект.
c == d — разные объекты вне кэша. Используй .equals() для сравнения!

BY Java tests


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/java_quizes/217

View MORE
Open in Telegram


telegram Telegram | DID YOU KNOW?

Date: |

How Does Telegram Make Money?

Telegram is a free app and runs on donations. According to a blog on the telegram: We believe in fast and secure messaging that is also 100% free. Pavel Durov, who shares our vision, supplied Telegram with a generous donation, so we have quite enough money for the time being. If Telegram runs out, we will introduce non-essential paid options to support the infrastructure and finance developer salaries. But making profits will never be an end-goal for Telegram.

telegram from ua


Telegram Java tests
FROM USA