Thursday 9 May 2013

Difference Between Instance Data Member and Static Data Members

 Types of data members in Java:

We known that every single java program must be written with respect to class, and a class is containing a collection of data members and method. In Java program data members from the class are classified as two types. They are

  1.  Instance data member’s
   2.  static data members

           Instance data members
        Static data members
1. Instance's data members are those whose memory space is creating every single time,"when we create an object."
1. Static data members are those whose memory space is creating only once. When the class is a loader into main memory irrespective of the number of object are created.
2. If the data member of a class is taking a specific value, than we must take the data member as instance.
2. If the data member of a class is taking a specific value, "then we must take the data member as instance."
3. Programatically instance data members declaration should not be preceded by keyword static.
Syntax:-
    Data type V1, V2……….
3. Programmatically instance's  data members declaration should not be preceded by keyword static.
Syntax:
    Data type V1, V2……….
4. Every single instance data member must be access with the respective object name.

Objname.instance data member name
4. All the static data members in Java must be access with the respective class name.

Classname.static data member name
5. All the values of instance data members are not sharable.

5. All the values of static data members are sharable.
6. All the instance data members are known as object's  level data members, because they depend on object name and independent from class name.

EX:- Int PIN,STNO,
6. All the static data members are known as class's  level data members, because they depend on class and independent from object name.

Static string INDIACAP,crsname;

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More