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 giangboul = 6;
int flanur = 2;
double ri = 4.0;
int mingpit = 4;

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

5 * giangboul * 5 * 3 * flanur - 4 * 3 + 0 * ri - mingpit / 5

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

boolean sebun = true;
double pioldpuc = 3.0;
double eario = 5.0;
double ha = 3.0;
int nekfoss = 8;
boolean resaess = false;
int enas = 6;
double grelpism = 3.0;
double asm = 4.0;
boolean fli = true;

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

sebun || pioldpuc <= 7 != eario >= 8 || ha <= 5 || nekfoss == 5 && resaess != (enas != grelpism) && 9 >= 1 || asm >= 1 && !fli

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 + 10 + "11"

Solution

Things to double-check in your solution:


Related puzzles: