011-002-003
Constructor Overloading: Person Class
Easy
Problem Description
constructor Overloading: Person class
In this problem, you will create a program that defines two constructors in a Person class (one with no arguments and one with arguments), instantiates objects using each constructor, and displays the information to standard output.
Learning Objective: Understand how to define multiple constructors with different arguments
Define two constructors in Person class: one with no arguments and one with arguments. Choose the appropriate constructor based on situation.
Input
Line 1: Name (string)
Line 2: Age (integer)
Output
Default: Unknown, 0 years
Custom: [name], [age] years
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up