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 sa = 8;
double oantpha = 3.0;
int pueckclo = 3;

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

3 * 3 * 1 - (sa - 3 + oantpha * 7 - pueckclo - 8) + 2

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

boolean mufri = false;
boolean qi = false;
double frixsi = 4.0;
double fangsriol = 1.0;
double vusmberm = 3.0;
boolean oic = true;
double musmio = 4.0;
boolean fosm = true;

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

!mufri != !(4 < 0) != (9 == 7) == qi != frixsi > fangsriol == vusmberm < 9 == oic && !(musmio != 1) || fosm

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 + 10

Solution

Things to double-check in your solution:


Related puzzles: