Wednesday, June 26, 2013

Answers of Concepts of Programming Languages Chapter 11

Review Questions
1. The two fundamental kinds of abstraction are process abstraction and data abstraction
2. Abstract data type is a data type that satisfies the following conditions :

  • The representation of objects of the type is hidden from the program units that use the type, so the only direct operations possible on those objects are those provided in the type's definition
  • the declarations of the type and the protocols of the operations on objects of the type, which provide the type's interface, are contained in a single syntactic unit.
4. A facility for defining abstract data type in a language must provide a syntactic unit that encloses the declaration of the type and the prototypes of the subprograms that implement the operations on objects of the type.
5. The design issues for ADT are
  • the form of container for the interface to the type
  • whether abstract data type can be parameterized
  • what access controls are provided and how such controls are specified
  • the language designer must decide whether the specification of the type is physically separate from its implementation
7. The private part is visible to the compiler
8. The semantic difference is that objects of a type that is declared limited private have no built-in operations.
9. Package specifications provide the interface of the encapsulation and the body package provides the implementation of most of the entities named in the associated package specification
10. The with clause makes the names defined in external packages visible
11. The use clause eliminates the need for explicit qualification of the references to entities from the named package.
12. C++ classes are types, Ada packages are more generalized encapsulations that can define any number of types.
14. Member function of a C++ class can be defined in two distinct ways : the complete definition can appear in the class, or only in its header.
15. Destructors are often used as a debugging aid, in which case they simply display or print the values of some or all of the object's data members before those members are deallocated
16. No value returned

Problem Set
8. The drawbacks of using user-defined generic classes :
  • they cannot store primitives
  • the elements cannot be indexed
9. The default constructor is called instead
10. The two conditions are 
  • The representation of objects of the type is hidden from the program units that use the type, so the only direct operations possible on those objects are those provided in the type's definition
  • the declarations of the type and the protocols of the operations on objects of the type, which provide the type's interface, are contained in a single syntactic unit.
11. Because C# uses garbage collection for most of its heap objects
12. Classes in Ruby are made dynamic by simply including additional class definitions that specify the new members.

No comments:

Post a Comment