‎2006 Dec 08 5:56 AM
hi,
wat is the difference betn public and private and protected in aba objects.
thanks,
ganesh
‎2006 Dec 08 6:12 AM
hi,
Public Section:
main class can access
sub class can access
friend class can access
Protected Section:
main class can access
sub class can access
friend class can access
Private Section:
main class can access with the help of public mehod
sub class cannot access
friend class can access
‎2006 Dec 08 6:01 AM
Public Section
All of the components declared in the public section are accessible to all users of the class, and to the methods of the class and any classes that inherit from it. The public components of the class form the interface between the class and its users.
Protected Section
All of the components declared in the protected section are accessible to all methods of the class and of classes that inherit from it. Protected components form a special interface between a class and its subclasses. Since inheritance is not active in Release 4.5B, the protected section currently has the same effect as the private section.
Private Section
Components that you declare in the private section are only visible in the methods of the same class. The private components are not part of the external interface of the class.
‎2006 Dec 08 6:12 AM
hi,
Public Section:
main class can access
sub class can access
friend class can access
Protected Section:
main class can access
sub class can access
friend class can access
Private Section:
main class can access with the help of public mehod
sub class cannot access
friend class can access
‎2006 Dec 08 6:21 AM
Hi ganesh,
Basically the idea of sections(public, protected and private) is to restrict the access to those variables/itabs, etc that you declared in a given section. Here are its description:
Public Section
All of the components in the public sections are visible to all users of the class, and to the methods of the class and its subclasses. The public components form the external interface between the class and its users.
Protected Section
All of the components in the protected section are visible to the methods of the class and its subclasses. This section forms a special interface between the class and the classes that inherit from it.
Private Section
The components that you declare in the private section are only visible in the methods of the class itself. They are not visible at all externally. The private components form no part of the external interface between the class and its users.
Regards,
pankaj singh.
edited by pankaj singh.
‎2006 Dec 08 6:29 AM
Hi Ganesh,,
No Matter which technology we are going to use,the OOPs concepts are going to remain same, so as in ABAP also.
regards
Ashutosh
reward point if helpfull.
‎2006 Dec 08 6:29 AM
‎2006 Dec 08 6:34 AM
hi ganesh,
Of the three Access Specifiers,
components declared as,
PUBLIC -> is accessable by any other class, also the base class, sub class and as well the friend class can access that component.
PROTECTED -> can be accessed by both base class and sub class, but by declaring a public method.A friend class say B can access the protected componenet of class A , as its taken as public(ie class A gives the permission for class B to take it as public.)
PRIVATE -> this can be accessed only by the class in which the component is declared. here again, a friend class say B can access the private componenet of class A , as its taken as public(ie class A gives the permission for class B to take it as public.)
Also, to access a private component, it can be done with thehelp of the public component of the same class,where in protected component is declared.
hope this info would be of help to u.
all the best.