2007 Dec 23 9:12 AM
2007 Dec 26 11:30 AM
Hi Soman,
we need to declare attributes in a local class with in a private section
to avoid access by others class means only objects of that class can access it.
For Ex. In a company some documents are private and confidencial only employee can see it. same way only objects of that calss can acess private objects.
if you are going with inheritance we need decalre the attributes in a public section so that inherited class can access it. you can also use Protedted class wich can be access by inherited class
Kindly Award Points If You Find The Reply Helpful.
Cheers,
Chaitanya.
2007 Dec 23 12:48 PM
Hi
To PROTECT the data to acess the data from out side classes
http://help.sap.com/saphelp_nw70/helpdata/en/c3/225b6554f411d194a60000e8353423/content.htm
2007 Dec 24 5:22 AM
Naresh is right, but perhaps you think it a little odd to have a private section in a local class, seeing as the local class can't be accessed outside the program anyway. The reason for doing it, is data encapsulation. By being specific about what data can be used under what circumstances, you have a better defined data model, and so you reduce the scope for error.
While you may be well aware of how your variables and methods should be used, the programmer who maintains your program in two years time may not be. By using good encapsulation, you prevent him from making some errors. If an attribute is private, he can't access it outside the class. If he decides to make it public, he can of course just change the class - but he has to do it deliberately.
Defining variables and methods with the correct scope is vital to writing good programs.
matt
2007 Dec 26 11:30 AM
Hi Soman,
we need to declare attributes in a local class with in a private section
to avoid access by others class means only objects of that class can access it.
For Ex. In a company some documents are private and confidencial only employee can see it. same way only objects of that calss can acess private objects.
if you are going with inheritance we need decalre the attributes in a public section so that inherited class can access it. you can also use Protedted class wich can be access by inherited class
Kindly Award Points If You Find The Reply Helpful.
Cheers,
Chaitanya.
2007 Dec 26 12:15 PM
>
> Hi Soman,
>
...
>
> if you are going with inheritance we need decalre the attributes in a public section so that inherited class can access it. you can also use Protedted class wich can be access by inherited class
>
If you declare attributes that are to be inherited you should use protected. You should only use public if access is required outside of the class. Public access is always the LAST choice, not the first.
matt
2007 Dec 27 6:14 AM
Hi
To secre the data with in the class and not to access from out side the class
The private components of the superclass are not visible though they exist in the subclass. You can declare private components in a subclass that have the same names as private components of the superclass. It is seen that each class works with its own private components. The another point that we note is that methods which a subclass inherits from a superclass use the private attributes of the superclass and not any private components of the subclass with the same names.
2007 Dec 27 8:56 PM
Why do you answer this thread twice? Didn't you notice your original answer?
matt
2007 Dec 28 4:43 AM
he is not closing thread so i am giving him a clear information about this