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 pide = 5.0;
int a = 2;
double pogliol = 3.0;
double serpum = 1.0;

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

(pide - 4 % a / 3 * pogliol) * serpum % 8

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

double renchon = 3.0;
double falscheent = 4.0;
boolean po = true;
int pistess = 1;
double es = 1.0;
double jottro = 5.0;
double asm = 4.0;

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

renchon == falscheent != po && (pistess < es && 8 >= jottro || 6 > asm) != 6 <= 1

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

Solution

Things to double-check in your solution:


Related puzzles: