Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is the difference in attributes defined in the public versus private section of a class?

Answer Posted / Eram Khan

"The primary difference between attributes defined in the public and private sections of a class in SAP ABAP (Object Oriented) lies in their visibility. Public attributes (DATA or FIELDS defined outside any SECTION) can be accessed from anywhere, including other classes. On the other hand, private attributes (DATA or FIELDS defined within a section such as PRIVATE SECTION, PROTECTED SECTION, or HIDDEN SECTION) are only accessible within their defining class and its subclasses. Here's an example:nn```abapnCLASS zcl_example DEFINITION.n PUBLIC SECTION.n CLASS-DATA: gt_public TYPE STANDARD TABLE,n gv_private TYPE i.nENDCLASSnCLASS zcl_example IMPLEMENTATION.n METHOD method1.n DATA: lv_local TYPE i.n APPEND lv_local TO gt_public.n ASSIGN gv_private TO lv_local.n ENDMETHODn``` In the example above, gt_public is a public attribute and gv_private is a private attribute. "

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

No New Questions to Answer in this Category !!    You can

Post New Questions

Answer Questions in Different Category