Objects in Java?
An object is an Instance of a class.
Creating an Object:
Employee e;
e = new Employee();
---> The 1st statement creates an object reference in stack memory.
---> The 2nd statement is used to create (or) give birth to an object for an employee.
---> The object is created in Heap memory.
---> Here "e" is called an object reference which is used to point the address of employee object.
---> By default all object references will have null values.
---> Object references are always created in stack memory whereas objects are created in Heap memory.
An object is an Instance of a class.
Creating an Object:
Employee e;
e = new Employee();
---> The 1st statement creates an object reference in stack memory.
---> The 2nd statement is used to create (or) give birth to an object for an employee.
---> The object is created in Heap memory.
Objects in Java |
---> Here "e" is called an object reference which is used to point the address of employee object.
---> By default all object references will have null values.
---> Object references are always created in stack memory whereas objects are created in Heap memory.
No comments:
Post a Comment
Please comment below to feedback or ask questions.