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 phecpo = 2;
int oli = 9;
int zacra = 9;
int heoun = 2;

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

9 - 2 % 1 * phecpo + 6 % oli % zacra / heoun

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

int iss = 3;
boolean badrion = false;
int tawheaet = 5;
boolean untsa = true;
int runda = 8;
boolean censpousm = false;
int xiing = 9;

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

8 != iss != badrion && tawheaet > 6 == untsa != !(runda <= 4) || censpousm != 6 <= xiing

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: