Fields, Methods, and Access Levels
by, 03-02-2012 at 04:13 PM (1267 Views)
- Java classes consist of methods and fields. A field is same as a C++ data member & a method is similar to a C++ member function.
- Each method & field possess an access level:
o private: access is possible in this class only
o (package): access is possible in this package only
o protected: access is possible in this package only & also in all subclasses.
o public: access is possible anywhere this class is present.
- Every class consist of these 2 possible access levels:
o (package): class objects can be manipulated & declared only by the help of code present in this package
o public: class objects might be manipulated & declared by the help of code present in any package.