Computer Science 3675
Summer 2002
Practice questions for quiz 4

  1. Write a clearly legible T to the left of each of the following that is true, and a clearly legible F to the left of each that is false.

    1. In a typeless language, all type checking done at run time.

    2. Standard ML is a strongly typed language. Therefore, in Standard ML, it is not possible to get a type error at run time.

    3. Polymorphism is most useful in designing custom applications, and is rarely used in function libraries.

    4. Programs written in an object-oriented style tend to be organized significantly differently from programs written in a functional or procedural style.

    5. The class is an important concept of object-based programming.

    6. In most object-oriented languages, some type checking must be done at run time.

  2. Polymorphism without type variables typically requires that a programmer defeat the compile-time type system. Give an example where the type system would need to be defeated without type variables, but where type variables would allow the compiler to perform type checking.

  3. What is the most general polymorphic type of function f defined by f(x) = tail(right(x))? Use type variables. Function right takes the left-hand member of an ordered pair.

  4. What is the most general polymorphic type of the Astarte function filter? Use type variables. Filter is defined so that (filter f L) a list of all members x of list L such that f(x) is true. For example, if function positive returns true on a positive number and false on a nonpositive number, then (filter positive [9,-2,-3,6]) = [9,6].

  5. In object-oriented programming, is a private data field of an object accessible only to that one object, or is it possible for other objects to access it directly?

  6. In a single-inheritance object-oriented language, is there a limit on the number of base classes that a class can have?

  7. In object-oriented programming, you imagine that objects carry functions with them. Yet, the functions are not really stored with the objects. How does an object locate its functions? How does it know which functions to select? What is the name of the system support that is responsible for locating functions?

  8. How does the mechanism for inheriting variables work in single-inheritance object-oriented languages? Is there a separate implementation of each selector for each class, or does one implementation of each selector work for all classes? How do the selector(s) work?

  9. What is an abstract class?

  10. What are the characteristics of a virtual functions? What makes it virtual?