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 tro = 9;
int a = 8;
int me = 9;
int ofird = 8;

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

tro / 1 + 8 - a - me + 3 % 9 * ofird * 1 % 6

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

boolean psiduk = false;
double eei = 2.0;
boolean diack = false;
double nel = 4.0;
boolean prubad = false;
int santiocs = 4;
double ia = 5.0;

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

!psiduk && 7 > eei == diack == (3 != nel) && !prubad || 1 < 0 != 6 <= santiocs || 6 != 6 != 9 > ia

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 + "10"

Solution

Things to double-check in your solution:


Related puzzles: