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: |

Traders also expressed uncertainty about the situation with China Evergrande, as the indebted property company has not provided clarification about a key interest payment.In economic news, the Commerce Department reported an unexpected increase in U.S. new home sales in August.Crude oil prices climbed Friday and front-month WTI oil futures contracts saw gains for a fifth straight week amid tighter supplies. West Texas Intermediate Crude oil futures for November rose $0.68 or 0.9 percent at 73.98 a barrel. WTI Crude futures gained 2.8 percent for the week.

However, analysts are positive on the stock now. “We have seen a huge downside movement in the stock due to the central electricity regulatory commission’s (CERC) order that seems to be negative from 2014-15 onwards but we cannot take a linear negative view on the stock and further downside movement on the stock is unlikely. Currently stock is underpriced. Investors can bet on it for a longer horizon," said Vivek Gupta, director research at CapitalVia Global Research.

telegram from no


Telegram Java tests
FROM USA