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 tasmed = 9;
int e = 4;
int qesh = 2;
int adveck = 7;

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

9 + tasmed / e - qesh * 0 % 4 / adveck

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

int er = 2;
double nesia = 4.0;
double veac = 1.0;
boolean orhad = true;
int ae = 7;
boolean i = false;

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

er != nesia || veac < 7 || orhad == (9 == 7) == 3 <= ae == !i

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

Solution

Things to double-check in your solution:


Related puzzles: