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 sqopra = 5.0;
double ouind = 1.0;
double e = 4.0;
int wio = 7;
int flartra = 3;

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

sqopra * ouind % e * 9 / wio / (2 + 2 + 0 * flartra % 6)

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

boolean xoss = false;
boolean spisrid = true;
int pra = 1;
int cew = 3;
boolean vinghirm = true;
double hesm = 5.0;
double noer = 3.0;
double frent = 5.0;
int angu = 7;

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

xoss == spisrid || pra > cew || (4 <= 1 != vinghirm || 7 >= 1) == 1 <= hesm == 7 >= noer != frent < angu

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"

Solution

Things to double-check in your solution:


Related puzzles: