Question 1 of 10
A greenhouse misting valve requires both sensors to be true. What text does this Java code display?
boolean humid = true;
boolean shaded = true;
System.out.print(humid && shaded);
- A. false
- B. true
- C. humid
- D. 2
A greenhouse misting valve requires both sensors to be true. What text does this Java code display?
boolean humid = true;
boolean shaded = true;
System.out.print(humid && shaded);
A museum pass is inverted before it is printed. What text does this Java code display?
boolean expired = true;
System.out.print(!expired);
A gallery door uses ! before ||. What text does this Java code display?
boolean closed = true;
boolean member = true;
System.out.print(!closed || member);
A bakery timer uses && and || without parentheses. What text does this Java code display?
boolean p = false;
boolean q = true;
boolean r = true;
System.out.print(p && q || r);
A plow dispatcher mixes !, &&, and ||. What text does this Java code display?
boolean fog = true;
boolean ice = false;
boolean plow = true;
System.out.print(!fog && ice || plow);
The method ding prints D when it runs. What text does this Java code display?
public boolean ding()
{
System.out.print("D");
return true;
}
boolean fresh = true;
System.out.print(fresh || ding());
A bakery divides loaves among ovens. What text does this Java code display?
int ovens = 0;
int loaves = 24;
boolean busy = (ovens != 0) && (loaves / ovens >= 6);
System.out.print(busy);
A library desk uses hour bounds and a weekend flag. What text does this Java code display?
int hour = 9;
boolean weekend = false;
boolean open = hour >= 8 && hour < 17 || weekend;
System.out.print(open);
The method tap prints T each time it runs. What text does this Java code display?
public boolean tap()
{
System.out.print("T");
return false;
}
System.out.print(tap() && tap());
The method buzz prints B when it runs. && is evaluated before ||. What text does this Java code display?
public boolean buzz()
{
System.out.print("B");
return true;
}
int slots = 0;
boolean full = false;
System.out.print(!full && buzz() || (slots > 0) && (9 / slots == 3));