Challenge: Inherit from Person
Tâche
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.
Solution
Tout était clair ?
Merci pour vos commentaires !
Section 4. Chapitre 6
single
Demandez à l'IA
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion
Génial!
Completion taux amélioré à 4.17
Challenge: Inherit from Person
Glissez pour afficher le menu
Tâche
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.
Solution
Tout était clair ?
Merci pour vos commentaires !
Section 4. Chapitre 6
single