On some occasions, you might want to access parent class data from a child class. Declaring the parent class field as public would violate the principle of information hiding, but declaring it private would make it inaccessible. How can the proper level of security be achieved?
What will be an ideal response?
If you want a derived class property or method to be able to access a parent's field, then it cannot be private. However, if you don't want other, nonchild classes to access the field, then it cannot be public. The solution is to create the field using the modifier protected, which provides you with an intermediate level of security between public and private access. A protected data field or method can be used within its own class or in any classes extended from that class, but it cannot be used by "outside" classes. In other words, protected members can be used "within the family"-by a class and its descendants.
You might also like to view...
When the ____ symbol is used with a choice list, the element can contain any number of occurrences of child elements or PCDATA, or it can contain no content at all.
A. + B. * C. ? D. ^
When creating a citation, in the Create Source dialog box, choose the ________ arrow to specify if your source is from a Web page or a book
A) Format B) From Source C) Type of Source D) Resource
Workflows within SharePoint define the level of access that is granted to a site, page, list, library, or item
Indicate whether the statement is true or false
Which of the following commands is used for a DHCP server to list the configured range of IP addresses and statistics for the number of leased addresses?
A) show ip dhcp binding B) show ip dhcp pool C) show ip dhcp network D) show ip dhcp range