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 arce = 4;
double sousan = 5.0;
double ciout = 2.0;
double pren = 5.0;
int dul = 1;
double i = 4.0;

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

arce / 8 % (sousan + ciout - pren * dul + i - 6 % 5) + 8

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

double whes = 4.0;
boolean el = false;
int wentwa = 7;
double aqiss = 5.0;
double de = 4.0;
double hespran = 4.0;
double ece = 1.0;
int is = 3;

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

whes != 9 || el == 5 >= 1 == (wentwa != 2) == 3 <= aqiss == de < 8 != 1 <= hespran == ece <= is || 7 >= 1

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: