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 ded = 1.0;
int te = 8;
int deusle = 9;
double ang = 3.0;
double osh = 4.0;

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

8 - ded * 4 / 5 / 0 * te - 1 + deusle - ang - osh

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

double ci = 4.0;
double erpack = 2.0;
double icsa = 2.0;
boolean de = false;
boolean is = false;
boolean cou = false;
boolean ka = false;
boolean ildel = true;
int pearad = 8;
int ouchu = 5;
double co = 3.0;

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

ci != 0 == !(erpack < icsa) || de || !is != cou == ka || ildel != !(pearad < 9) || ouchu == co

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: