What is Class
1)Class is a master copy or Blue print or template of object. Anything which is physically present can be considered as object such as home, glass, dog, man , table etc are examples of object.
Example:When you wan’t to build a home, floor map (i.e where would be kitchen , bedroom, hall etc) of home on the paper is nothing but the blue print or master copy. In java, master copy or Blue print or template of object is called as class and Actual implementation of class is called as Object. In this example of a home, your actual home building is Object.
2)Class is a data type.
3)Class is declared using keyword class
4)Structure of class:
Example of class shown below:
Example of class as data type shown below:
When we create an object , its get created in heap memory. we don’t use object to access states and behaviors of object rather we use object reference to access states and behaviors of object. so when we create an object , we use class name as data type of object reference which is shown below.