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 o = 2.0;
int ciureasm = 6;
int dictish = 9;

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

o % 8 * ciureasm / 3 % 1 - 5 - 7 / 2 - 8 % dictish

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

boolean olbri = false;
int lal = 1;
double hodspos = 4.0;
int haph = 7;
boolean buintscod = true;
double knic = 5.0;
boolean gostpec = false;

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

!(0 >= 2) != olbri == ((4 == 2) && !(lal >= hodspos) == haph < 3 != buintscod == 9 <= 9) || knic == 6 || gostpec

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

Solution

Things to double-check in your solution:


Related puzzles: