Pages

Monday 24 June 2013

Chapter 11

An assignment from Mr. Tri Djoko Wahyono (again). As what the title said, it is the answer for some question (12 numbers, quite randomly in Review Qustion and 5 numbers in Problem Set) in Chapter 11 in "Concept of Programming Language" book.

Review Question

1. What are the two kinds of abstraction in programming languages?
The two fundamental kinds of abstraction in contemporary programming languages are process abstraction and data abstraction.

8. What is the difference between private and limited private types in Ada?
Limited private is more restricted form and objects of a type that is declared limited private have no built-in operations.

10. What is the use of the Ada with clause?
With clause makes the names defined in external packages visible; in this case Ada. Text_IO, which provides functions for input of text.

11. What is the use of the Ada use clause?
Use clause eliminates the need for explicit qualification of the references to entities from the named package.

12. What is the fundamental difference between a C++ class and an Ada package?
Ada packages are more generalize encapsulations that can define any number of types.

15. What is the purpose of a C++ destructor?
The purpose of a C++ desctructor is 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. What are the legal return types of a desctructor?
Destructor has no return types and doesn’t use return statements.

21. What are initializers in Objective-C?
Constructors.

22. What is the use of @private and @public directives?
The use is to specify the access levels of the instance variables in a class definition.

27. Where are all Java methods defined?
All Java methods are defined in a class.

30. What is a friend function? What is a friend class?
a “friend” of a given class is allowed access to public, private, or protected data in that class. Normally, function that is defined outside of a class cannot access such information.
Class that can access the private and protected members of the class in which it is declared as a friend. On declaration of friend class all member function of the friend class become friends of the class in which the friend class was declared.

37. What is the name of all Ruby constructors?
Initialize.

Problem Set
9. What happens if the constructor is absent in Java and C++?
It will be made automatically by the built-up in.

10. Which two conditions make data type “abstract”?
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. The type’s interface does not depend on the representation of the objects or the implementation of the operations. Also, other program units are allowed to create variables of the defined type.


11. Why is the destructor of C# rarely used?
Although C# allows destructors to be defined, because it uses garbage collection for most of its heap objects, destructors are rarely used.

12. How are classes in Ruby made dynamic?
Classes in Ruby are dynamic in the sense that members can be added at any time. This is done by simply including additional class definitions that specify the new members. Moreover, even predefined classes of the language, such as String, can be extended.

17. The namespace of the C# standard library, System, is not implicitly available to C# programs. Do you think this is a good idea? Defend your answer.
I think it is not, because it reduces its efficiency.

No comments:

Post a Comment