Java - Classes and Objects
What will be printed when this code runs?
class Light {
boolean isOn = false;
void toggle() { isOn = !isOn; }
void show() { System.out.println(isOn ? "On" : "Off"); }
}
public class Test {
public static void main(String[] args) {
Light light = new Light();
light.show();
light.toggle();
light.show();
}
}