Skip to main content\(
\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 1.28 Assessment: Boolean Logical Operators
Subsection 1.28.1 Subgoals for evaluating an assignment statement
Determine resultant data type of expression
Update variable for pre-increment or pre-decrement operators (side effect)
Evaluate arithmetic expression according to operator precedence
If an assignment statement (=), is Left Hand Side (LHS) a variable? Check data type of value against data type of variable.
Update variable for post-increment or post-decrement operators (side effect)
Exercises 1.28.2 Exercises
1.
Q1: Given the following, what value is stored in variable answer
?
int x = 5, y = 3, z = 1;
boolean answer;
answer = (x < y) && (z < y);
true
false
2.
Q2: Given the following, what value is stored in variable answer
?
int x = 5, y = 3, z = 1;
boolean answer;
answer = (x < y) || (z < y);
true
false
3.
Q3: Given the following, what value is stored in variable answer
?
int x = 5, y = 3, z = 1;
boolean answer;
answer = (x <= 5) && (y >= 2);
true
false
4.
Q4: Given the following, what value is stored in variable answer
?
int x = 5, y = 3, z = 1;
boolean answer;
answer = (y == z) || (z == x);
true
false
5.
Q5: Given the following, what value is stored in variable answer
?
int x = 5, y = 3, z = 1;
boolean answer;
answer = (x <= 3) || ((z <= y) && (z == 1));
true
false
You have attempted
of
activities on this page.