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 ti = 3.0;
double mo = 4.0;
int chiiss = 7;
int phe = 5;

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

1 / 9 / ti % 9 + mo - 5 / chiiss / 7 - 9 + phe

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

boolean feto = true;
boolean e = false;
double epsik = 3.0;
boolean ocit = true;
double licent = 3.0;
double ul = 5.0;
int chli = 4;
int rurac = 1;

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

feto != !e != 3 <= 0 != !(4 > 5) != !(5 < epsik) == ocit != (licent == ul) && 8 > 4 || chli == rurac

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: