Challenge: Inherit from Person
Завдання
Swipe to start coding
Practice using inheritance by building on your knowledge from previous chapters. Your goal is to implement a base class and a derived class using proper constructors and field initialization.
- Define a
Personclass with two public properties:NameandAge. - Implement a constructor in
Personthat initializes theNameandAgeproperties. - Define a
Studentclass that inherits fromPerson. - Add a public property
StudentIdtoStudent. - Implement a constructor in
Studentthat takes parameters forname,age, andstudentId, and initializes all three properties appropriately.
Рішення
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 4. Розділ 6
single
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат
Suggested prompts:
Can you explain this in more detail?
What are the next steps I should take?
Can you provide an example?
Чудово!
Completion показник покращився до 4.17
Challenge: Inherit from Person
Свайпніть щоб показати меню
Завдання
Swipe to start coding
Practice using inheritance by building on your knowledge from previous chapters. Your goal is to implement a base class and a derived class using proper constructors and field initialization.
- Define a
Personclass with two public properties:NameandAge. - Implement a constructor in
Personthat initializes theNameandAgeproperties. - Define a
Studentclass that inherits fromPerson. - Add a public property
StudentIdtoStudent. - Implement a constructor in
Studentthat takes parameters forname,age, andstudentId, and initializes all three properties appropriately.
Рішення
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 4. Розділ 6
single