Challenge: Inherit from Person
Taak
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.
Oplossing
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 4. Hoofdstuk 6
single
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.
Geweldig!
Completion tarief verbeterd naar 4.17
Challenge: Inherit from Person
Veeg om het menu te tonen
Taak
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.
Oplossing
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 4. Hoofdstuk 6
single