What are Java Classes and Objects?
1611
09-Nov-2015
Devesh Kumar Singh
09-Nov-2015The term ‘class’ refers to the actual written piece of code which is used to define the behavior of any given class. So, a class is a static piece of code that consists of attributes which don’t change during the execution of a program – like the method definitions within a class. It is like a blueprint for creating different objects which defines its properties and behaviors. . A class can contain fields and methods to describe the behavior of an object.
The term ‘object’, however, refers to an actual instance of a class. Every object must belong to a class. Objects are created and eventually destroyed – so they only live in the program for a limited time. While objects are ‘living’ their properties may also be changed significantly. Objects exhibit the properties and behaviors defined by its class.