byte x = 0;
byte y = (--x<0) ? ++x : -x;
Result of the code execution will be:
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.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Sign Up Now
or Subscribe for future quizzes