Notes
Ternary operator (Right associative). This operator acts as a short-hand for if-then-else statements. If x, a Boolean, is true, y is the result. Otherwise z is the result.
Integer timeNow = 20;
String result = (timeNow < 18) ? 'Good day.' : 'Good evening.';
System.debug(result);
DEBUG | Good evening
Integer num=13;
String result = Math.mod(num,2)==0 ? 'Even Number' : 'Odd Number';
System.debug(result);
DEBUG | Odd number