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 chralfap = 3.0;
double angmel = 4.0;
int ramcir = 8;
int oss = 2;
int fo = 1;

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

7 + chralfap + angmel % ramcir / oss / fo / 5 - 3 * 9

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

boolean we = true;
boolean chirtra = false;
int prac = 6;
boolean ezen = false;
double ades = 3.0;
boolean bontor = true;

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

(we == chirtra == (prac != 1)) != ezen && ades < 8 && !(2 <= 5) != bontor == 1 < 8

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"

Solution

Things to double-check in your solution:


Related puzzles: