โ Back to Encapsulation
Question 498
Toggling Encapsulated State
Toggling Encapsulated State
TheLightSwitchclass has a privateboolfieldisOnthat startsfalse. Add a methodToggle()that flips it and a read-only propertyIsOnthat returns its value. Do NOT write aMainmethod. After one call toToggle()the program prints: True
Expected Output:
True
Topics:
Encapsulation
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cw, cr, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.