Class: A class is a way of binding the data and associated methods in a single unit. Any JAVA program if we want to develop then that should be developed with respective class only.

In object oriented programing generally we write two types of methods. They are member methods and non-member methods.

  •  A member method is one which comes under the scope of the class. I java we use only member methods.
  • Non-Member methods are those which are not comes under the scope of the class. JAVA does not allow non-member methods at all.

class Diagram

 

Syntax of Class:

Class <classname>

{

Variable declaration;

Methods definition;

}

In the above syntax Class is keyword which is used for developing or creating user defined data types. Classname represents a JAVA valid variable name and it is treated as name of the class. Class names are used for creating objects.

Class contains two parts: Variable Declaration and Method Definitions. Variable declaration represents what type of data members which we use as a part of the class. Method definition represents the type of methods which we used as the path of the class to perform an operation.

Example of  class:

Class student
{
Int stno;

String stname;

Float marks;

String cname;

String  getgrade ()

{

—————

—————

}

}

Whenever we define a class there is no memory space for data members of the class. Memory space will be created for the data members of the class when we create object.