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 ptou = 1;
double de = 2.0;

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

6 + (7 / 3 + 5 + 6) + 8 / ptou % de * 0

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

boolean hiqe = true;
double un = 4.0;
int giobri = 4;
boolean zunt = true;
int binphlal = 7;
double triwoss = 1.0;
int clen = 1;

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

hiqe != 9 <= un && 4 != giobri == zunt || binphlal > 3 == (triwoss > clen || 3 < 6 == (3 != 6))

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: