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 growhoss = 3;
int eo = 1;
double prih = 5.0;
double o = 3.0;

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

growhoss / eo % 9 % 7 % 6 / prih / o * 8

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

double um = 2.0;
int rilcreng = 2;
boolean mo = true;
double bentad = 5.0;
int accrid = 7;
double dalil = 4.0;
boolean ar = true;
int ratcold = 6;

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

5 == um || 4 < rilcreng || mo || bentad != accrid == 4 > dalil == ar == 7 <= ratcold

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: