← Back to Classes
Question 309
Person Introduction Class
Person Introduction Class
Create a class named Person that stores a name (string) and an age (int) in two fields. Give it a constructor that takes name and age (in that order) and saves them. Then add a method called Introduce() that returns a string in the exact form "Hi, I'm<name>and I am<age>years old." (for example, "Hi, I'm Alice and I am 30 years old."). The runner code will create a Person and print the result of Introduce().
Expected Output:
Hi, I'm Alice and I am 30 years old.= newline. The output ends with a newline — print one after the last line.
Hints4 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.