Skip to content

Instantly share code, notes, and snippets.

@azeezat
Last active February 28, 2020 09:50
Show Gist options
  • Save azeezat/a690ef85b08033a31c2cbcfd71110db9 to your computer and use it in GitHub Desktop.
Save azeezat/a690ef85b08033a31c2cbcfd71110db9 to your computer and use it in GitHub Desktop.
class Lamp {
boolean isOn;
void turnOn() {
isOn = true;
}
void turnOff() {
isOn = false;
}
void displayLightStatus() {
System.out.println("Light on? " + isOn);
}
}
class ClassObjectsExample {
public static void main(String[] args) {
Lamp l1 = new Lamp();
Lamp l2 = new Lamp();
l1.turnOn();
l2.turnOff();
l1.displayLightStatus();
l2.displayLightStatus();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment