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 ledco = 5.0;
int pri = 7;
double rocru = 1.0;
int oss = 1;
double tantpe = 1.0;
int eoun = 2;

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

ledco % pri % rocru * oss / 8 * tantpe % eoun * 0

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

double prul = 4.0;
boolean chre = true;
int ma = 2;
boolean u = false;

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

!(2 < prul) || 8 == 0 == 4 >= 9 == 6 < 1 != chre && 4 <= ma == u

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: