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 dass = 2;
int lurtid = 9;
double miol = 1.0;

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

(dass * lurtid * 9 / 6 % 8 * 6 - 0 - 3 / miol / 1) % 8

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

int eper = 9;
double ea = 1.0;
int ceostsac = 8;
boolean ma = true;
boolean omae = false;
boolean uincial = true;
boolean deadcias = false;
double kasas = 1.0;
int tismde = 4;
boolean he = true;

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

0 == eper && (2 <= ea && 9 != ceostsac == !ma && !omae) || !uincial && deadcias != 6 >= kasas != 5 > tismde || he

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 + "10" + 11

Solution

Things to double-check in your solution:


Related puzzles: