Wednesday, 30 March 2016

Objects And Classes

Objects and Classes:
 As Java is an object orient programming, it uses Objects. These objects are the instances of the Class.
 Class is a container of methods, blocks, member variables. the instance of the class is object. so the instance of the class (object of the class ) acts as class and provides the members, methods, blocks etc for the use of processing. Generally, the class is main for defining a member, developing methods on the member etc. so the objects have some basic properties: They are
1. State : the value of the object
2. Behaviour : what it does or what method or functionality it has.
3. Identity : The identity of  the object is unique. each object has its own identity , this id is used by JVM internally for recognising and remembering the object uniquely.

Class contains the following :
 1. Member variables.
 2. Methods or Functions
 3. Blocks. etc

Member Variables may be locla variables , global variables or instance variables.
the variables that are declared inside the method is called local variables. these can be used only in the method. they cannot be used outside the method. on the other hand Global variables or instance variables are declared in the class but not in the method. these variables can be accessed in the entire class where ever it is necessary.

Methods and Functions:
Both are same in java. the methods or functions are of two types , those which returns the values and those which doesnot returns the value.

The methods that returns a value is of type variable that it returns. and the methods hich doesnot return a value is of void type.

we can have static blocks also.

No comments:

Post a Comment