← Back to Classes
Question 97
Create a Lamp Class
Create a Lamp Class
Create a class named Lamp with one private member: boolean isOn. Requirements: 1. Make a default constructor Lamp() that sets isOn to true. 2. Create a public methodgetIsOn()that returns isOn. IMPORTANT: Do NOT write a main method for this question. Your class will be tested with a hidden Main class that creates a Lamp object and printsgetIsOn().
Expected Output:
true= newline. The output ends with a newline — print one after the last line.
Hints2 available
Sign in to use hintsTopics:
Classes
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.