_
1) CLASS
_
WHAT : * class is tha blueprint or template that helps to creat tha real world entites.
why use : * class is used to avoid tha repected code.
* to orgainze code in tha neat way.
* class is tha creat many object easilly.
when : * when you want to creat multiple similer object
_
2) ## OBJECT_
what : * Real thing created from that design (like an actual car you drive).
*An instance of a class.
*It is a real-time entity created from a class.
*Object has state (data/variables) and behavior (methods/functions).
why use :
Reusability :Once you create a class, you can create many objects from it.
Memory Management: Each object has its own copy of variables (state).
Communication between objects: Objects can call methods of other objects.
3) ## VARIABLE
What: * Veriable is the container, thats hold tha value.
* is the name thats refer to the value in a program
Why : variable is used to store a data from used input.
When : if u want keep some data u needed tha variable.
4) method
* method is a set of instruction.
* a method is a some block of code thar.t perform a task
* always written inside tha class.
Why use :
* code reusesability : once write tha code. Use for many times.
* avoide repetation.
No need to write tha same code again and again.
When : * to make tha program easy to modify and you need to store a. Data
*encapsulation *
What : binding tha data and protect it. To user didn't to direct access from tha out side classes.
Why use :
* secure. Protect data from out side misuse
* bind data and method in one class
* It is used for data. Hiding. And access control
When : When we need controlled access using methods (getters/setters).
Inheritance
What : * one class properties and beheviours is used to another or inherit to another class
* is tha parent child relation ship
Why use : child class can use parent class variable and methods.
* change in parent class reflect in child class automatically .
When : Use inheritance to reuse code and model an ‘is-a’ relationship between classes."
Top comments (0)