Challenge: Inherit from Person
Aufgabe
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.
Lösung
War alles klar?
Danke für Ihr Feedback!
Abschnitt 4. Kapitel 6
single
Fragen Sie AI
Fragen Sie AI
Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen
Großartig!
Completion Rate verbessert auf 4.17
Challenge: Inherit from Person
Swipe um das Menü anzuzeigen
Aufgabe
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.
Lösung
War alles klar?
Danke für Ihr Feedback!
Abschnitt 4. Kapitel 6
single