← Foundations path
.NETFoundations 1 / 37

Class and object

“What is the difference between a class and an object?”

The blueprint you write once, and the things built from it while the app runs.

See it

In your codewritten onceIn memorymade while the app runsheapclass LoanIdAmountRateMonths──────────Emi()ChangeRate()car = 0x1Abike = 0x2BLoan @ 0x1AAmount 500000Rate 9.5Months 60Emi() = 10,500.93Loan @ 0x2BAmount 90000Rate 11Months 24
1 / 7A class is a blueprint. It lists what every loan has, and what a loan can do.

In plain words

A class is a blueprint you write once in code. An object is a real thing built from that blueprint while the app runs. One class can build many objects, and each keeps its own values. is the class. Your car loan and your bike loan are two objects.

Say it in the interview

In the lending API

Two real files from the lending API. Press Next line to walk through them.

Lending.sln · where these 2 files sit
  • src/Domain/Servicing/
  • tests/Domain.UnitTests/Servicing/
Diagram · step 1A class is a blueprint. It lists what every loan has, and what a loan can do.
In your codewritten onceIn memorymade while the app runsheapclass LoanIdAmountRateMonths──────────Emi()ChangeRate()car = 0x1Abike = 0x2BLoan @ 0x1AAmount 500000Rate 9.5Months 60Emi() = 10,500.93Loan @ 0x2BAmount 90000Rate 11Months 24
Loan.cs · line 4 · 1 of 10class Loan declares a new type. No loan exists yet. This only describes what a loan will look like.

What they ask next

Interviewers check that you can explain every line. Tap a question to open it.

Traps

With AI tools

AI tools write a class like Loan in seconds. Interviewers now ask "why this and not that" about each line, for example why or why decimal. In the research for this app, a smooth first answer that falls apart on that question was the strongest rejection signal.

Read more: Microsoft Learn: classes · Microsoft Learn: objects · decimal vs double · Math.Round and MidpointRounding