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 tinttrant = 1;
double ungras = 2.0;
int cu = 9;
double epru = 2.0;
int hickpod = 9;
int eress = 3;

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

5 % (tinttrant % ungras / cu) % epru * 5 - 5 - hickpod + eress

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

boolean a = true;
boolean thas = false;
boolean iio = true;
boolean facca = false;
int iphrerd = 4;

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

a == thas == iio || (facca && 3 < 3 == (iphrerd != 9)) || !(3 >= 1) && !(2 > 2)

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: