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 ircess = 5.0;

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

0 - 8 - ircess - 9 + 4 * 1 / 5 % 7

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

double netorm = 4.0;
double preae = 3.0;
int sastqad = 8;
double uex = 4.0;
boolean irl = false;
int koscil = 4;
double hiu = 5.0;
double schoswesh = 5.0;
double gloc = 5.0;
int bosxil = 6;

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

netorm > 6 && preae <= 0 && sastqad != uex != irl == !(koscil <= hiu) && schoswesh != gloc && 8 < bosxil

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: