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 orju = 4.0;
double intfa = 4.0;
int la = 9;
int beopund = 2;
int scidfis = 5;

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

orju - 7 - 2 - 0 + (0 + 6 + intfa * 4 % la) / beopund - scidfis

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

double gilli = 4.0;
double oet = 4.0;
boolean hentzem = true;
int prengu = 6;
double prurer = 5.0;
double panpre = 1.0;
double e = 1.0;
int benhiss = 4;
double uadew = 3.0;
boolean ne = true;
boolean cinshess = false;
int odusm = 4;

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

gilli < oet != hentzem && 7 >= prengu != prurer >= 6 && (panpre >= e && benhiss < uadew && 8 >= 5 && ne && cinshess) && odusm >= 9

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: