Constructor Delegation Practice
Task
Swipe to start coding
You're working with a class that has multiple constructors. During code review, you were asked to refactor them using initialization lists for better performance and cleaner code.
- The default constructor should delegate to the main constructor, passing default values.
- The constructor that sets only the name should also delegate, using defaults for the other fields.
- The one that sets name and age should delegate too, passing a default salary.
- The fully parameterized constructor stays as is.
Solution
solution
Everything was clear?
Thanks for your feedback!
SectionΒ 2. ChapterΒ 6