โ Back to Encapsulation
Question 453
Getter and Setter Methods
Getter and Setter Methods
Create a classThermostatwith aprivate intfieldtemperature. Add aSetTemperature(int value)method that stores the value and aGetTemperature()method that returns it. Do not write aMainmethod. AfterSetTemperature(72)the program prints: 72
Expected Output:
72
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.