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 to = 5;
int tre = 2;

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

to % (4 * tre) * 6 % 4

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

int rholsan = 1;
int bu = 5;
double ro = 3.0;
double kud = 4.0;
int ludis = 3;

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

rholsan > bu || 5 != ro && 2 > 1 && kud == ludis

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

Solution

Things to double-check in your solution:


Related puzzles: