โ Back to Encapsulation
Question 477
Getter Method
Getter Method
TheStudentclass stores a private fieldnameset by the constructor. Add a public methodGetNamethat returns the value ofname. The tester prints it. Do NOT write aMainmethod. Fornew Student("Ada")the program prints: Ada
Expected Output:
Ada
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.