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 chonsguss = 2.0;
int pedspo = 6;
double ecest = 3.0;
int otcor = 1;

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

4 + chonsguss % pedspo * 0 / ecest % 1 + otcor

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

double shocis = 3.0;
int thaniang = 7;
double ha = 2.0;
double ia = 2.0;
int loiud = 5;
int trudjin = 6;

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

6 < 1 || 0 > shocis || (thaniang != ha && 8 < ia == (3 == 8) || !(!(loiud <= trudjin)))

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"

Solution

Things to double-check in your solution:


Related puzzles: