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 hous = 4.0;
int zapsion = 3;
int reac = 7;
double ac = 4.0;
int mesce = 9;
double soank = 1.0;

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

1 % hous % zapsion + (7 % reac % ac * mesce) * 2 / soank

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

int mio = 1;
boolean od = true;
double psiaar = 3.0;
double astrex = 1.0;
boolean osson = true;
int sudlird = 4;
int is = 7;
double pente = 5.0;

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

6 <= mio || !od != psiaar >= astrex == osson && (sudlird <= 4 == 7 > is && 6 <= 8 && 4 < pente)

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: