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 ke = 5.0;
double shis = 5.0;
int prescis = 9;
int noui = 4;
int ismuss = 3;

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

9 / (5 * ke % shis) * prescis - 8 * noui / ismuss

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

double magess = 2.0;
int ceim = 3;
double iolil = 1.0;
boolean ciapon = true;
boolean laltra = false;

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

4 >= 1 != 7 <= 4 && (1 < 6 != (7 == magess)) == ceim > iolil && ciapon == laltra

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: