
Classes and Objects In Java
📝What is 'Class' in Java? :
- A Class is a Logical entity or Blueprint using which we can create multiple Objects.
- We cannot create an Object without a Class. Hence Step.1 create a class and then create any number of objects.
- Multiple Objects created using the same class are called as Similar Object or Identical Object.
- Every Object work independently, I.e.., if one Object is modified or destroyed then it does not affect another Object.
📝What is 'Object' in java? :
- An object is a Real-world Physical entity.
- Anything which has Physical presence or Physical appearance can be considered as an Object.

🌟Object Contains two Important things Or Properties:-
- States
- Behavior
- After successful compilation, the compiler generates default Constructor. Where the constructor name must be the same as a class name.
Example:
🎖Some Important Points Of Object:-
- In java, Objects are stored in Heap Memory. Memory allocation & Memory deallocation i.e, complete Memory management is taken care by JVM.
- Jvm creates an object in heap Memory when we call the Constructor using a "new" Keyword.
- Object address is represented in Hexa Decimal format.
- The Class name and object name must be the same.
- This address is started in a variable called a reference variable, which helps in accessing the data present in the Object.
🎖How To Create Object in java, and how it's Stored In Memory:-
Example(1):
Example(2):
🌟Object Reference / Object Address :
- A Reference is the one which stores an Object address, Hence Object Reference is present in Heap Memory.
Example:
🌟what Are the States of an object:
- The State of an object is nothing but the property/information or data which describes an Object.
- The data member is nothing but a data holder, which holds / stores the data.
States:- It is always representing features of an Object.
➢ Variable.
➢ Constant.
- In the case of Variable, the data Varies I.e.., the data Changes.
- Programmatically non-final data members are called Variable.
- Constant is the data member which represents Fixed Value.
- Programmatically we declare Constant using Final Keyword.
final name = “Dog” ; → Constant.
name = “ Tommy” ; → Variable.
Since an Object is derived from a class, the States & Behaviors of an Object must be first declared in class, Hence States & Behaviors are contents of the class.
Example: