Java Programming
About Lesson

A class is a user-defined data type in java.  A class can consist of group of values and operations to manipulates these values.  The variables of class are known as Objects.

General form of class:

class className

{

            datatype varName_1;

            datatype varName_2;

            ….

            datatype varName_n;

            rtype method_1(arguments)

            {

                        ….

                        …

            }

            rtype method_2(arguments)

            {

                        ….

                        …

            }

            …

            …

            rtype method_n(arguments)

            {

                        ….

                        …

            }

}

The data and methods of a class are known as its members.

All objects of a class will have their individual copy of data members but share the global copy of methods.

Creating an object involves the following two steps:

  1. Declaration of object
  2. bind the object to its class

The new operator of java dynamically allocates memory for an object, returns a reference(address) to the object and binds the reference with the object.

You cannot copy content of this page