Username: Save?
Password:
Home Forum Links Search Login Register*
    News: Keep The TechnoWorldInc.com Community Clean: Read Guidelines Here.
Recent Updates
[April 24, 2024, 11:48:22 AM]

[April 24, 2024, 11:48:22 AM]

[April 24, 2024, 11:48:22 AM]

[April 24, 2024, 11:48:22 AM]

[April 03, 2024, 06:11:00 PM]

[April 03, 2024, 06:11:00 PM]

[April 03, 2024, 06:11:00 PM]

[April 03, 2024, 06:11:00 PM]

[March 06, 2024, 02:45:27 PM]

[March 06, 2024, 02:45:27 PM]

[March 06, 2024, 02:45:27 PM]

[March 06, 2024, 02:45:27 PM]

[February 14, 2024, 02:00:39 PM]
Subscriptions
Get Latest Tech Updates For Free!
Resources
   Travelikers
   Funistan
   PrettyGalz
   Techlap
   FreeThemes
   Videsta
   Glamistan
   BachatMela
   GlamGalz
   Techzug
   Vidsage
   Funzug
   WorldHostInc
   Funfani
   FilmyMama
   Uploaded.Tech
   MegaPixelShop
   Netens
   Funotic
   FreeJobsInc
   FilesPark
Participate in the fastest growing Technical Encyclopedia! This website is 100% Free. Please register or login using the login box above if you have already registered. You will need to be logged in to reply, make new topics and to access all the areas. Registration is free! Click Here To Register.
+ Techno World Inc - The Best Technical Encyclopedia Online! » Forum » THE TECHNO CLUB [ TECHNOWORLDINC.COM ] » Programming Zone » JAVA
 Java: Information Hiding
Pages: [1]   Go Down
  Print  
Author Topic: Java: Information Hiding  (Read 3048 times)
Khushi
Global Moderator
Adv. Member
*****



Karma: 4
Offline Offline

Posts: 329

Hello!!


View Profile
Java: Information Hiding
« Posted: January 03, 2007, 12:10:28 AM »


Information hiding is a key feature of java. When declaring a variable or a method it can be one of four things: private, protected, or public or default. The way you specify the type is using one of the three keywords or none at all.

For example:

Code:
// Default 
int i = 0;

//public
public int i = 0;

Public: When you declare a variable public it means that it can be accessed anywhere in the program. If you inherit from that class you would have access to all of the public variables.

Private: When a variable is private it cannot be seen anywhere except for the class is instantiated in. If you use a class you will not be able to see any private data.

Protected: If a variable is protected you only have package access (useful when developing libs). That means that you will only see the variable in the package that it is instantiated in and all its subclasses.

Default: Default package access is achieved when there is no specifier (private, public, or protected). Default package access means that the variable is available within the package that it is created in but not in the package subclasses. Basically you can think of it as a package private.

When creating variables within a method you can only specify one keyword (final). You cannot create public, private, or protected, or even default variables. When you create an Object within a method it is only available within the method it is created in.

Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Copyright © 2006-2023 TechnoWorldInc.com. All Rights Reserved. Privacy Policy | Disclaimer
Page created in 0.125 seconds with 25 queries.