Search This Blog

If you have any problem or question please write in the comments. We will try to solve and send you the solution. Not just that we will also post your problems solution on our blog.

Object oriented programming

Understanding class:
                                    The class is at the core of java. It is the logical construct upon which the entire java language is built because it defines the shape and nature of an object. Any concept you wish to implement in a java program must be encapsulated within a class. The most important thing to understand about a class is that it defines a new data type. Once defined, this new type can be used to create objects of that type. We can say that a class is template for an object, and an object is an instance of a class. A class is declared by the use of class keyword. Classes can (and usually do) get much more complex. The general form of a class is:

class class-name
{
type instance-variable1;
type instance-variable2;
//...
type instance-variableN;

type methodname1(parameter-list)
{
//body of method
}
type methodname2(parameter-list)
{
//body of method
}
//...
type methodnameN(parameter-list)
{
//body of method
}
}

The data or variables defined within a class are called instance variables. The code is contained within methods. Collectively, the methods and variables defined within a class are called members of the class. Thus it is the methods that determine how a class data can be used. Notice that the general form of a class does not specify a main() method. Java classes do not need to have a main() method.