Why is an object called an instance of a class?
Answers
An object is called an instance of a class as every object created from a class gets its own instances of the variables defined in the class. Multiple objects can be created from the same class.
⇩⇩⇩⇩⇩⇩⇩
Let's make this simple. First, start with the class .
Class:- A class is a blueprint of an object.
According to this statement, it’s clear that A class is something that doesn't exist in real world. So we need objects to represent the class.
For example :- You are representing the Class Student. So you are the real-world entity of the class Student.
Object:- An object is a real-world entity which have State, behavior, and Identity. i.e. You are the object of class Student.
Note:- An object is the example of a class that is going to represent it in the real world that's why it is called as the Instance(or example) of the class.
Both the term is used very interchangeably. So don’t get confuse.
✪✪✪✪✪✪✪✪✪✪✪
հօթҽ íԵ հҽlթs
վօմ
✪✪✪✪✪✪✪✪✪✪✪