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 preltre = 4.0;
int spost = 5;
double iesprung = 1.0;
double pussong = 5.0;

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

(3 * 2 / preltre + 1 + spost) % iesprung * 8 * pussong * 0

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

boolean frantmos = true;
double ciapost = 2.0;
boolean gitet = false;
int sacsi = 5;
double phercie = 4.0;
boolean se = false;
boolean cous = true;
boolean a = false;

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

!frantmos || !(ciapost > 1) == gitet || sacsi != phercie == !se && 4 > 4 || cous || a

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: