Class in java ?


Class in Java is the selection of similar types of object. From one class we can create n number f objects and n number of objects getting together to make a class.

A class is declared using class keyword.

Pro-grammatically class is nothing but a keyword which is used to declare any user-defined class.

It is the blueprint or skeleton of objects.

A class is a user-defined prototype from which objects are created.

Class can’t be physical.

The class is a logical entity.

Combining these language features into classes is known as encapsulation.

A class contains both data and code that operate on that data.

A class can contain 3 types of variable

The class is a logical container which never allocates any memory.

  • In java point of view, a class is the collection of 4 types of member:-
  1. Data member/Variable
  2. Function
  3. Constructor
  4. Block

Rules of class:-

  • Never starts with a digit
  • Space is not allow
  • The keyword is not allow
  • The symbol is not allowed except ‘ _ ’ and  ‘ &’.

Example :-

Class Test_a


Int x=100; //datamember

Void show() //function



Test_a() //constructor



Static() //static block


//nonstatic block





Also Read:-Data member/Variable

Also Read:-Function

Also Read:-Constructor

Also Read:-Block

Leave a comment

Your email address will not be published. Required fields are marked *