What is the value of myField after the execution of the following code snippet?
long myField = 5 >= 5 ? 1+2 : 1*1; if(++myField < 4) myField += 1;
B.
The initial assignment of myField follows the first branch of the ternary expression.
Since 5 >= 5 evaluates to true, a value of 3 is assigned to myField.
In the next line, the pre-increment operator increments the value of myField to 4 and returns a value of 4 to the expression. Since 4 < 4 evaluates to false, the if-then block is skipped.
This leaves the value of myField as 4, making Option B the correct answer.