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 us = 2.0;
int en = 6;
int dalrius = 9;

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

8 % 5 - 7 * us * (0 % en % 6 / 7) % 8 % dalrius

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

double padroa = 1.0;
double houa = 1.0;
int i = 8;
boolean tintnuad = true;
int hibon = 1;
boolean flesm = false;
double cearcra = 3.0;
int stiamlist = 7;

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

padroa == houa && i > 1 != (5 == 3) || tintnuad || 7 == hibon == flesm && cearcra == 5 || 0 > stiamlist != 6 < 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: