Concepts of Programming Languages

(Sean Pound) #1
Programming Exercises 521


  1. Explain the dangers of C’s approach to encapsulation.

  2. Why didn’t C++ eliminate the problems discussed in Problem 7?

  3. What are the advantages and disadvantages of the Objective-C approach
    to syntactically distinguishing class methods from instance methods?

  4. In what ways are the method calls in C++ more or less readable than
    those of Objective-C?

  5. What are the arguments for and against the Objective-C design that
    method access cannot be restricted?

  6. Why are destructors rarely used in Java but essential in C++?

  7. What are the arguments for and against the C++ policy on inlining of
    methods?

  8. Describe a situation where a C# struct is preferable to a C# class.

  9. Explain why naming encapsulations are important for developing large
    programs.

  10. Describe the three ways a client can reference a name from a namespace
    in C++.

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

  12. What are the advantages and disadvantages of the ability to change
    objects in Ruby?

  13. Compare Java’s packages with Ruby’s modules.


PROGRAMMING EXERCISES



  1. Design an abstract data type for a matrix with integer elements in a lan-
    guage that you know, including operations for addition, subtraction, and
    matrix multiplication.

  2. Design a queue abstract data type for float elements in a language that
    you know, including operations for enqueue, dequeue, and empty. The
    dequeue operation removes the element and returns its value.

  3. Modify the C++ class for the abstract stack type shown in Section 11.4.2
    to use a linked list representation and test it with the same code that
    appears in this chapter.

  4. Modify the Java class for the abstract stack type shown in Section 11.4.4
    to use a linked list representation and test it with the same code that
    appears in this chapter.

  5. Write an abstract data type for complex numbers, including operations
    for addition, subtraction, multiplication, division, extraction of each of

Free download pdf