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 twel = 5.0;
int priountsulf = 7;
double ithe = 3.0;

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

7 - 1 + 3 + 7 + 3 % twel % priountsulf + ithe / 5 / 3

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

int hantqi = 1;
boolean miol = false;
double malost = 3.0;
int fi = 8;
double panpi = 4.0;
double tessshan = 1.0;
double gecmi = 2.0;

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

8 == 3 && 4 == 9 && 4 == 9 == (9 == hantqi) == miol == (2 == malost) == 4 > fi || !(panpi >= 4) != (!(tessshan == gecmi))

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: