What Is A Java Class ?

Definition :

- Java Class is nothing but a template for object you are going to create (or) its a blue print by using this we create an object.

- In simple words we can say its a pattern which we define and every object we define will follow the pattern. class are fundamental building.

What does Java Class Consist :

  • When you create class in java the first step is keyword class and then name of the class or identifier we can say.

  • Next is class body which starts with curly braces { } and between this all things related with that class means their property and method will come here.

Class Syntax :

<access specifier> class <identifier>

Access Specifiers Of Class :

Java class has mainly two type of access level and they are listed below.

Default: class objects are accessible only inside the package.

Public: class objects are accessible in code in any package.

Members of Class :

The contents of the body of a class consists of a collection of <members>. Members consist of fields and methods.

Field : Things in the Java language which hold data, or hold pointers to objects are called fields. Think of fields as variables.

Method : Method is a set of statement that perform a particular task. It is similar to function is c/c++.

This are basic's of Class in java and will look in detail about Class in next tutorial.

No comments:

Post a Comment