Skip to main content
Contents
Prev Up Next Scratch ActiveCode Profile
\(
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)
Section 2.25 Assessment: Boolean Relational Operators
Subgoals for evaluating an assignment statement.
Determine resultant data type of expression
Update variable for pre operators based on side effect
Solve arithmetic equation, operator precedence
Is the Left Hand Side (LHS) of the assignment statement a variable? Check the data type of the value on right hand side (RHS) against data type of LHS variable.
Update variable for post operators based on side effect
Exercises Exercises
1.
Q1: Given the following, what value is stored in variable
answer
?
int x = 5;
int y = 3;
int z = 1;
boolean answer;
answer = x <= z;
2.
Q2: Given the following, what value is stored in variable
answer
?
int x = 5;
int y = 3;
int z = 1;
boolean answer;
answer = y >= z;
3.
Q3: Given the following, what value is stored in variable
answer
?
int x = 5;
int y = 3;
int z = 1;
boolean answer;
answer = x > z + y;
4.
Q4: Given the following, what value is stored in variable
answer
?
int x = 5;
int y = 3;
int z = 1;
boolean answer;
answer = z < y - z;
5.
Q5: Given the following, what value is stored in variable
answer
?
int x = 5;
int y = 3;
int z = 1;
boolean answer;
answer = ((x * y) + (x * z)) != ((z * x) + (y * x));
You have attempted
of
activities on this page.