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 ano = 1.0;
double bifesh = 4.0;
int phegleing = 1;
int pinint = 9;
double irmdot = 5.0;
double uin = 4.0;
double heg = 5.0;

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

ano % bifesh % 2 * phegleing * (pinint + irmdot + uin * heg)

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

double dehas = 2.0;
int sturer = 3;
double plec = 2.0;
int e = 6;

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

!(9 <= 4) != 6 >= 0 == ((6 == 3) == 1 > 6 == dehas > sturer) && 3 != plec != (!(e == 9))

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

Solution

Things to double-check in your solution:


Related puzzles: