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 arphge = 7;
int trel = 7;
int mu = 9;
double tre = 5.0;
int al = 2;

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

7 - arphge - trel % 4 / mu - tre * 2 % al

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

int daullis = 7;
double criode = 3.0;
boolean phlambad = false;
double masple = 2.0;
double blalstras = 1.0;
boolean me = false;

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

!(5 <= daullis) || criode > 1 && phlambad == 1 > 3 != 7 < masple || !(blalstras > 0) != me

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: