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 skucta = 3.0;
double ne = 2.0;
int lihit = 1;
double kodpo = 5.0;

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

(3 + skucta * ne / lihit - kodpo) * 7 / 8

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

double worfa = 3.0;
double wucie = 5.0;
boolean ma = false;
int as = 5;
int podte = 3;
double fi = 1.0;

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

worfa >= wucie && 9 <= 8 == ma && 9 >= as && podte > 7 && 5 >= fi

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: