Classes In Java

The class is 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. As such,the class forms the basis for object oriented programming in Java.Any concept we want to implement in java program must be encapsulated within the a class.

                                    A class can be defined as a template that describes the behaviour that object of its type.A class is the blueprint from which individual objects are created.  A class can have any number of methods to access the value of various kinds of methods. 


A class can contain any of the following variable type:-

  1. Local variable:-Variables defined inside methods, constructors or blocks are called local variables. The variable will be declared and initialized within the method and the variable will be destroyed when the method has completed.
  2. Instance Variable:-Instance variables are variables within a class but outside any method. These variables are instantiated when the class is loaded. Instance variables can be accessed from inside any method, constructor or blocks of that particular class.
  3. Class Variables:-Class variables are variables declared with in a class, outside any method, with the static keyword.

Syntax:- A class is declared by the use of the class keyword. The syntax is given as below:-

class userdefined_class_name


                Member variable;

               Member function/method;


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s