byte x = 0;
byte y = (--x<0) ? ++x : -x;
System.out.println(y);
Result of the code execution will be:
Explanation
Expression result will have type int, because the type of the third operand of the ternary operator in the result will be int. Therefore, you need explicit conversion for successful compilation.

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Продовжуйте вивчати
тести з Java
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести