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 isas = 5.0;
double iececk = 5.0;
double ta = 2.0;

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

isas - 7 + 8 - iececk - 9 % ta / 4 - 6

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

double en = 4.0;
int enes = 2;
int vemi = 3;
double or = 4.0;
int ashbo = 7;
double kir = 3.0;
boolean e = true;
int riadcon = 7;
double chiw = 5.0;

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

7 != en == enes >= vemi && or == 0 == (ashbo < 8 != (kir == 7) && e) != riadcon > chiw

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" + 8

Solution

Things to double-check in your solution:


Related puzzles: