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 jiaa = 5.0;
double of = 5.0;
double raal = 2.0;

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

2 * 8 * 0 - 8 + jiaa % of - raal

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

boolean flioccent = false;
boolean pline = false;
int oushen = 8;
double cu = 5.0;
boolean thi = true;
double geento = 4.0;
boolean ede = true;

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

(flioccent && !pline || oushen == cu && thi == geento <= 6 || !ede)

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: