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 u = 2.0;
double irher = 1.0;
double branmal = 4.0;
double o = 1.0;

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

2 - u / 0 - 8 * irher % branmal - o * 6 + 8

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

boolean febe = true;
boolean spler = true;
int sesstes = 5;
int qia = 3;
int bosm = 7;
int be = 3;
double ochan = 2.0;
int po = 7;
int sinton = 3;

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

febe && spler && 9 > sesstes != !(qia >= bosm) || be != ochan && 3 == 2 != 1 >= po == (5 != sinton)

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: