Drawing ASTs for expressions: Correct Solution


For each of the Java expressions below:

Be sure that your tree accurately reflects how Java would evaluate the expression.

Part 1

Given the following variables:

double sa = 5.0;
double tacliss = 3.0;
int preou = 2;

...draw the AST and evaluation results for the following expression:

sa % 8 % 4 - 0 / 3 * tacliss % preou

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

boolean neltood = false;
double iodphio = 5.0;
int veoupan = 1;
double fiss = 4.0;
double sisto = 2.0;
double scri = 5.0;

...draw the AST and evaluation results for the following expression:

neltood != (0 != iodphio) && !(4 < 0) && !(7 < 9) || veoupan == fiss == (sisto != scri)

Solution

Things to double-check in your solution:


Part 3

Draw the AST and evaluation results for the following expression:

0 + (1 + "2" + 3 + 4 + "5" + 6 + 7)

Solution

Things to double-check in your solution:


Related puzzles: