why is object called instance of a class?
Answers
Class is an collection of common attributes of n number of objects. When a class is defined, it doesn’t acquire any space in memory, it is only the attributes defined which must be common among all the objects of that class.Object is the physical existence of the class. Objects acquires memory when created.When we create an object in java, then only it acquires memory in RAM. Otherwise the class definition doesn’t acquire memory in RAM.Just as datatypes in java like int, float, char, double, long. These are the predefined classes in java. When we create an variable of these classes in java, an object is created of that particular class which is specified.Objects are the containers where we can store our data, perform different functions on it. Built-in datatypes in java are the predefined containers whereas the objects of our made class is the customized container.So that Objects are called as an Instance of class in JAVA
ᴏʙᴊᴇᴄᴛ ᴄᴀʟʟᴇᴅ ɪɴsᴛᴀɴᴄᴇ ᴏғ ᴀ ᴄʟᴀss
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.
ʙᴇ ʏᴏᴜʀs...................^_^