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 tiesspol = 9;
int bobon = 6;
double hasttro = 3.0;
double mi = 5.0;

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

2 * 5 * tiesspol % 8 - bobon + hasttro % 8 / mi

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

boolean koist = true;
boolean plonul = false;
double an = 5.0;
int icsca = 5;
double cismcik = 3.0;
boolean od = false;
int chlad = 6;

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

(koist || plonul == (an == icsca) || 0 <= cismcik) == od || 6 <= 5 || 6 != chlad

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: