PTS 1 REF 429 4 Explain encapsulation and information hiding ANS Real world

Pts 1 ref 429 4 explain encapsulation and information

This preview shows page 5 - 7 out of 7 pages.

PTS:1REF:4294.Explain encapsulation and information hiding.ANS:Real-world objects often employ encapsulation and information hiding. Encapsulation is the process ofcombining all of an object’s attributes and methods into a single package. Information hiding is the concept that other classes should not alter an object’s attributes—only the methods of an object’s own class should have that privilege.
Outside classes should only be allowed to make a request that an attribute be altered; then it is up to the class’s methods to determine whether the request is appropriate. When using a door, you usually are unconcerned with the latch or hinge construction features, and you don’t have access to the interiorworkings of the knob or know what color of paint might have been used on the inside of the door panel. You care only about the functionality and the interface, the user-friendly boundary between the user and internal mechanisms of the device. Similarly, the detailed workings of objects you create within object-oriented programs can be hidden from outside programs and modules if you want them to be. When the details are hidden, programmers can focus on the functionality and the interface, as people do with real-life objects.PTS:1REF:4325.List the three parts of a class definition.6.Describe what class diagrams list by convention.7.Explain what private access means in object oriented programming.8.List the two identifiers within a method that always mean the exactly same thing when you write an in-stance method in a class.ANS:When you write an instance method in a class, the following two identifiers within the method always mean exactly the same thing:• any field name• this, followed by a dot, followed by the same field namePTS:1REF:4519.Describe what happens any time a local variable in a method has the same identifier as a class field.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture