Question 1 of 10
A lake dock opens only when both conditions are true. What text does this Java code display?
boolean calm = true;
boolean staffed = false;
System.out.print(calm && staffed);
- A. true
- B. false
- C. calm
- D. 0
A lake dock opens only when both conditions are true. What text does this Java code display?
boolean calm = true;
boolean staffed = false;
System.out.print(calm && staffed);
A shuttle boards if the rider is late or a standby seat exists. What text does this Java code display?
boolean late = false;
boolean standby = true;
System.out.print(late || standby);
A locker prints a compound check. ! is applied before &&. What text does this Java code display?
boolean locked = false;
boolean keyed = false;
System.out.print(!locked && keyed);
Java evaluates && before ||. What text does this Java code display?
boolean a = true;
boolean b = false;
boolean c = false;
System.out.print(a || b && c);
A trail sign uses !, &&, and || together. What text does this Java code display?
boolean wet = false;
boolean cold = true;
boolean windy = false;
System.out.print(!wet || cold && windy);
A ferry estimates riders per open ramp. What text does this Java code display?
int ramps = 0;
int riders = 18;
boolean packed = (ramps > 0) && (riders / ramps > 4);
System.out.print(packed);
The method ping prints P when it runs. What text does this Java code display?
public boolean ping()
{
System.out.print("P");
return false;
}
boolean online = true;
System.out.print(online || ping());
A greenhouse heater uses relational tests inside a compound boolean. What text does this Java code display?
int temp = 4;
boolean frost = temp < 5 && temp != 0 || temp > 20;
System.out.print(frost);
The method stamp prints S when it runs. What text does this Java code display?
public boolean stamp()
{
System.out.print("S");
return true;
}
boolean dry = false;
System.out.print(dry && stamp());
The method trip prints T when it runs. && is evaluated before ||. What text does this Java code display?
public boolean trip()
{
System.out.print("T");
return true;
}
boolean alarm = false;
int gap = 0;
System.out.print(alarm && trip() || (gap > 0) && (10 / gap == 2));