Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

visibility

Former Member
0 Likes
434

what are mandatory things we have to follow in a program while using keywords public,private,protected

3 REPLIES 3
Read only

Peter_Inotai
Active Contributor
0 Likes
412

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

Read only

Former Member
0 Likes
412

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....

Read only

Former Member
0 Likes
412

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.