Chapter 3 – Selections –
8 test answers
Unlock all answers in this set
Unlock answers 8question
What is a conditional expression ?
answer
evaluates a condition based on an expression
Unlock the answer
question
What is the result of the conditional expression above?
answer
Result is the conditional expression is EXPRESSION1 if BOOLEAN-EXPRESSION is true; otherwise the result is EXPRESSION2
Unlock the answer
question
Suppose that, when you run the following program, you enter input 2 3 6 from the console. What is the output? public class Test { public static void main(String[] args) { java.util.Scanner input = new java.util.Scanner(System.in); double x = input.nextDouble(); double y = input.nextDouble(); double z = input.nextDouble(); System.out.println((x < y && y < z) ? "sorted" : "not sorted");
answer
Sorted
Unlock the answer
question
What is the format of System.out.printf("%3d#%2s#%3.2fn", 1234, "Java", 51.6653);
answer
displays 1234#Java#51.67
Unlock the answer