June 27, 2013

KBP chapter 11

Rickvian Aldi / 02PCT / 1601253441
Assignment By Mr. Tri Djoko Wahjono

Review Questions 1. What are the two kinds of abstractions in programming languages?
- Process abstraction and Data abstraction.

2. Define abstract data type.
-An abstract data type is a data structure, in
the form of a record, but which includes subprograms that manipulate its data.

3. What are the advantages of the two parts of the definition of abstract data
type?
-It is a weapon against complexity; a means of making large and/or complicated programs more manageable.

4. What are the language design requirements for a language that supports
abstract data types?

-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.

5. What are the language design issues for abstract data types?
-The first design issue for abstract data types is the form of the container for the interface to the type.
-The second design issue is whether abstract data types can be parameterized.
-The third design issue is what access controls are
provided and how such controls are specified.

15. What is the purpose of a C++ constructor?
-constructors are used to initialize the data members of newly created objects. A constructor
may also allocate the heap-dynamic data that are referenced by the pointer
members of the new object.

17. Where are all Java methods defined?
-Methods in Java must be defined completely in a class.

26. Why does Java not have destructor?
-destructor are obviated by Java’s implicit garbage collection

27. Where are all Java methods defined?
-Methods in Java must be defined completely
in a class.

28. Where are Java classes allocated?
-from the heap and
accessed through reference variables.


30. What is a friend function? What is a friend class?
-Friend functions have access to the private entities of the class where they are declared to be friends.Friend class is a class that can access the private entities of the class which has friend function in it.
37. What is the name of all Ruby constructors?
-Constructors in Ruby are named initialize.

Problem Set
4. What are the advantages of the nonpointer concept in Java?
answer: 
-Any task that would require arrays, structures, and pointers in C can be more easily and reliably performed by declaring objects and arrays of objects. Instead of complex pointer manipulation on array pointers, you access arrays by their arithmetic indices. The Java run-time system checks all array indexing to ensure indices are within the bounds of the array. You no longer have dangling pointers and trashing of memory because of incorrect pointers, because there are no pointers in Java.


10.Which two conditions make data type “abstract”?
answer :
-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 destructor of C# rarely used?
answer:
-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 are made dynamic?
answer:
-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,


15. Give one capability that Java 5.0 provides which C# 2005 does not.
answer:
-One capability that Java 5.0 provides that C# 2005 does not is wildcard classes.