Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Static vs Instance Demo | Static Classes and Members
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
C# OOP Class Construction Drills

bookChallenge: Static vs Instance Demo

Oppgave

Swipe to start coding

Write the complete Vehicle class from scratch, including all required fields, the static member, and the constructor.

  • Define a public static field TotalVehicles to track the total number of vehicles created.
  • Define two public instance fields: Make and Model.
  • Implement a constructor that takes two parameters: make and model.
  • In the constructor, assign the make parameter to the Make field and the model parameter to the Model field.
  • Each time the constructor is called, increment the TotalVehicles static field by one.

Løsning

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 3. Kapittel 6
single

single

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

Suggested prompts:

Can you explain this in simpler terms?

What are some examples related to this topic?

Where can I learn more about this?

close

bookChallenge: Static vs Instance Demo

Sveip for å vise menyen

Oppgave

Swipe to start coding

Write the complete Vehicle class from scratch, including all required fields, the static member, and the constructor.

  • Define a public static field TotalVehicles to track the total number of vehicles created.
  • Define two public instance fields: Make and Model.
  • Implement a constructor that takes two parameters: make and model.
  • In the constructor, assign the make parameter to the Make field and the model parameter to the Model field.
  • Each time the constructor is called, increment the TotalVehicles static field by one.

Løsning

Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 3. Kapittel 6
single

single

some-alt