Skip to content

Instantly share code, notes, and snippets.

@azeezat
Last active February 28, 2020 20:42
Show Gist options
  • Save azeezat/a0fe49954271be167734362b9ce8f42e to your computer and use it in GitHub Desktop.
Save azeezat/a0fe49954271be167734362b9ce8f42e to your computer and use it in GitHub Desktop.
interface LampInterface{
void turnOn();
void turnOff();
displayLightStatus()
}
class Lamp implements LampInterface{
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