Objects and classes are the fundamental parts of object-orientated programming technique. A class can contains both data as well as methods. A simple class having no method must contain a method known as main() method. Execution of any class starts from the main() method.
A class can have more than one instances (objects), let us consider a class employee having the employee details that serves for the employees of an organization, each time we create a new object for each employee. While all the employees share the same template (i.e. employee class).This section illustrates how to define our own classes, that includes declaring and defining of member variables, methods, and constructors. We also try to cover nesting of classes within other classes, enum and annotations.
An object is the combination of related states and behavior in which variables are just like states and the methods are just like behaviors (providing some functionality). In an object, variables store values for later use and methods are the unit of codes that provides a particular functionality. We can say objects are the basic units of the object-oriented programming.
Posted on: April 17, 2011 If you enjoyed this post then why not add us on Google+? Add us to your Circles