‎2007 Jun 18 8:46 AM
what are mandatory things we have to follow in a program while using keywords public,private,protected
‎2007 Jun 18 8:59 AM
You should set protected /if you have subclasses/ or private as much method and attributes as possible. Especially if they are used in another method and not meant to call/use from otuside.
Everything you want to use outside of the class should be public.
Peter
‎2007 Jun 19 4:48 AM
Sandeep,
before using these KeyWords we need to think that,
How much secure you need to keep the data ,which we are going to keep in that variables or the functionality of methods, from other programs.Finally depends on the confidentiality of data .
Private/protect--are secured
public --is global.
Pls. reward if useful....
‎2007 Jun 19 10:15 AM
Hi,
<b>Classes are broadly classified into three types :</b>
PUBLIC CLASS
This class is created using the addition CREATE PUBLIC to the class definition statement.
This class can be instantiated by the User, by the Own Class and by the Subclasses
PROTECTED CLASS
This class is created using the addition CREATE PROTECTED to the class definition statement.
This class can be instantiated only by the Own Class and by the Subclasses.
PRIVATE CLASS
This class is created using the addition CREATE PRIVATE to the class definition statement.
This class can be instantiated only by the Own Class.
<b>Visibility of Components of Class</b>
PUBLIC SECTION : The components in this section are visible to everybody, i.e. users, its own methods and its subclasses.
Therefore, public components form the external interface between the class and its users.
PROTECTED SECTION : The components are visible to the methods of the class and its subclasses.
Therefore, it forms a special interface between the class and its subclasses.
PRIVATE SECTION : Here, components are only visible to its own method.
A section may or may not be present, but whatever sections are present they should come in the same above order.
Regards,
Azaz Ali.