ANSWERS 2025(GRADED A+) DETAILED
ANSWERS!!
9) What kind of operator is the <= operator?
a) Ternary
d
b) Arithmetic
c) Inequality
d) Relational
10) Which of the following operators is used as a
relational operator?
b a) =<
b) <=
c) =
d) !
15) A store provides 10 percent discount on all items
with a price of at least $100. No discount is otherwise
applicable. Which of the following DOES NOT
correctly compute the discount?
a) double discount = 0;
if (price >= 100)
{
discount = 0.10 * price;
}
b) double discount = 0.10 * price;
if (price <= 100)
, {
discount = 0;
}
c) double discount;
b if (price < 100)
{
discount = 0;
}
else
{
discount = 0.10 * price;
}
d) double discount = 10;
if (price >= 100)
{
discount = 0.1 * price;
}
else
{
discount = 0;
}
16) Which of the following statements is (are) true
about an if statement?
I. It guarantees that several statements are always
III only executed in a specified order.
II. It repeats a set of statements as long as the
condition is true.
III. It allows the program to carry out different actions
depending on the value of a condition.
, 8/8/25, 1:45 PM CSE 110 - Exam 2 QUESTIONS AND VERIFIED ANSWERS 2025(GRADED A+) DETAILED ANSWERS!!
3) Which of the following statements is correct about
an if statement?
a) You must use braces if the body of an if statement
contains only a single statement.
b b) You can omit an else statement if there is no task
defined in the else branch.
c) You cannot use braces if the body of an if
statement contains only a single statement.
d) The number of opening braces can be different
from the number of closing braces.
7) The following code snippet contains an error. What
is the error?
if (cost > 100);
{
cost = cost - 10;
c }
System.out.println("Discount cost: " + cost);
a) Syntax error (won't compile)
b) Logical error: use of an uninitialized variable
c) Logical error: if statement has do-nothing
statement after if condition
d) Logical error: assignment statement does not show
equality
… 2/16