Skip to content

Latest commit

 

History

History
22 lines (15 loc) · 1.06 KB

DataMembers.md

File metadata and controls

22 lines (15 loc) · 1.06 KB

Types of data members in a class

In Java programming, data members are classified into 2 types

  • Instance/Non-static data member

  • Static data member

Non-Static Static
These are the variables whose memory space is created each and every time whenever we create an object These are the variables whose memory space is created only once whenever the class is loaded in the main memory
Instance data members are used to store specific value static data members are used to store common values
Each and every instance data member must be accessed with respect to object name Each and every data member must be accessed with respect to class name

Types of Methods in a class

There are 2 types of data members in a class

Non Static Method Static Method
These are used for performing repeated operations such as reading the record of for, database etc. These are recommended to perform one time operation such as opening a file, database etc.
We can access non-static methods wrt object name We can access static method wrt class name