← Back to Classes
Question 531
Age Validator Class
Age Validator Class
Create a classHumanwith a public propertyAgebacked by a private field. The getter returns the stored age; the setter stores the value but replaces any negative value with 0. Do not write aMainmethod. SettingAgeto 25 then reading it prints the output shown in Expected Output. SettingAgeto -5 then reading it prints: 0
Expected Output:
25= 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 (cw, cr, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.