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 fobhi = 1.0;
double seseu = 4.0;
double u = 5.0;
double basnon = 5.0;

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

8 - fobhi / 6 + seseu * u + 4 + basnon

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

double pe = 2.0;
double pebreou = 2.0;
boolean zilud = true;
double fric = 4.0;
double riar = 5.0;
double criartpsass = 5.0;
boolean prarmsploolf = true;

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

!(pe >= 6) || (9 < pebreou != zilud && fric < riar) || criartpsass > 4 && !prarmsploolf

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

Solution

Things to double-check in your solution:


Related puzzles: