โ Back to Encapsulation
Question 487
Constructor Overloading
Constructor Overloading
TheTimerclass has a private fieldseconds. Give it TWO constructors: a parameterless one that startssecondsat 0, and one that takes anint startand uses it. Also add aTick()method that adds 1 tosecondsand a read-onlySecondsproperty. Do NOT write aMainmethod. A newTimer()ticked twice prints: 2 Anew Timer(10)ticked once prints: 11
Expected Output:
2
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.