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:

int cang = 4;
int muvood = 5;

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

9 - 7 * 2 / 3 / cang % 8 / 8 / 7 / muvood

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

boolean urhac = true;
boolean meon = false;
double oincap = 5.0;
double veca = 5.0;
boolean es = false;
double padue = 2.0;
int jes = 6;
int roicnia = 3;

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

urhac || !meon != ((1 == 4) == (1 != oincap) == 3 >= veca == es || !(padue <= jes) && 0 < roicnia)

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 + 9

Solution

Things to double-check in your solution:


Related puzzles: