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 in = 5;
double shiontbacs = 1.0;
int clua = 9;
int dabar = 3;
int adfi = 8;
int o = 1;

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

in % shiontbacs - clua + (dabar / adfi) - 7 - 2 - o + 9

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

int bechind = 4;
int pripull = 9;
double pulsten = 5.0;
boolean be = true;
double pusse = 3.0;
int ac = 4;
boolean adert = true;
boolean haxa = false;
boolean feone = false;
int flanroor = 9;

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

(!(bechind >= pripull) != !(7 <= pulsten) == be && pusse != ac != adert) != haxa == feone && flanroor <= 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: