and Answers| Latest Update
Which of the following variables is used to store a condition that can be either true or false?
A. Logical
B. Conditional
C. Algebraic
D. Boolean ✔️✔️Boolean
Which of the following operators is used to combine two Boolean conditions?
A. $$
B. & &
C. %%
D. ## ✔️✔️& &
Which of the following expressions represents a legal way of checking whether a value for the
num variable is either less than 100 or more than 200?
A. if (num < 100 || num> 200)
B. if (num < 100 && num > 200)
C. if (num <= 100 && num >= 200)
D. if (num <= 100 || num >= 200) ✔️✔️if (num < 100 || num> 200)
Which of the following options checks that the string country is neither China nor Denmark?
, A. if (country.equals("China") || country.equals("Denmark"))
B. if (!(country.equals("China") || country.equals("Denmark")))
C. if (!country.equals("China") || !country.equals("Denmark")
D. if (!(country.equals("China") && country.equals("Denmark"))) ✔️✔️if
(!(country.equals("China") || country.equals("Denmark")))
Which of the following conditions tests for the user to enter the string "Hello"?
A. if (s = "Hello")
B. if (s.substring(0,5) == "Hello")
C. if (s == "Hello")
D. if (s.equals("Hello")) ✔️✔️if (s.equals("Hello"))
Which of the following conditions tests whether the user enters an integer value that will then
be assigned to the floor variable?
int floor = 0;
Scanner in = new Scanner(System.in);
System.out.print("Floor: ");
if (...)
{
floor = in.nextInt();
}
A. in.nextInt()
B. in.nextInt(floor)
C. in.fail
D. in.hasNextInt() ✔️✔️in.hasNextInt()