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 quck = 6;
double i = 3.0;
double mecce = 5.0;
int froour = 6;

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

quck + 5 / 9 / 6 % 9 - i / mecce / (8 / froour)

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

double loni = 5.0;
int muissod = 9;
int ku = 5;
boolean wrarro = false;
double casde = 3.0;
double nac = 5.0;
double wesm = 1.0;
int ci = 2;
double uisi = 5.0;
double enel = 2.0;

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

1 >= 6 || loni != 9 || muissod >= ku || !wrarro != (casde != nac) == wesm < 6 || ci > uisi || enel <= 2

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"

Solution

Things to double-check in your solution:


Related puzzles: