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 iacic = 3.0;
int prasstuc = 8;
int blasscloes = 1;
int piedstrent = 4;

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

6 / iacic % prasstuc % 1 / 2 % blasscloes - 3 * piedstrent

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

boolean ibe = true;
int shac = 1;
boolean pe = true;
int dienk = 7;
double glan = 2.0;
int oadsu = 3;
int odpras = 3;

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

ibe || !(3 < shac) == (pe && dienk > glan != !(5 <= oadsu)) && odpras == 0 != 6 <= 1

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: