Challenge: Inherit from Person
Tehtävä
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.
Ratkaisu
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 4. Luku 6
single
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme
Suggested prompts:
Can you explain this in more detail?
What are the next steps I should take?
Can you provide an example?
Mahtavaa!
Completion arvosana parantunut arvoon 4.17
Challenge: Inherit from Person
Pyyhkäise näyttääksesi valikon
Tehtävä
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.
Ratkaisu
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 4. Luku 6
single