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 uw = 9;
double oftches = 3.0;

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

uw + (9 % oftches + 3 / 1 % 5 * 3) - 2 + 0

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

int beassspu = 1;
double ta = 3.0;
double priolbues = 4.0;
int ul = 5;
double siffgis = 3.0;
double be = 1.0;
double pri = 2.0;
int na = 9;
int grar = 2;
boolean si = false;

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

8 != beassspu || ta == priolbues == ul <= siffgis && 1 == 0 || be >= pri != !(na >= grar) || !(!(1 <= 8)) != si

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: