DEV Community

pranavinu
pranavinu

Posted on • Edited on

CLASS & OBJECT

Class :
1)Class is a template or blueprint, we can be edit the statement which is inside the class
2)Class consist of more number of keyword
Ex: class, new, public, private etc.
3)Class is a logical entity, where JVM will won't allocate memory for class
4)Class name allows limited special char ($ and _)

5)Class name can allow the numeric values either in-between or at the end
Syntax:
Class
{

}

Object:
1)Object is the collection of variables and method
Variables: It is the data or the properties, that were stored inside the class
Method: It is the action, that were stored inside the class
2)It is a physical entity, JVM will allocate a memory for an object in heap, at a runtime

3)Heap: It is a memory space for java program, it provides a large space to store the object from java
4)Heap stores the object dynamically, based on the size of the object the space will be occupied

Syntax:
classname objectname = new classname();

new - java keyword
objectname - referance name

Top comments (0)