CSCI 3675 Summer 00 Practice questions for quiz 4

Note: I said that the quiz would only cover types, but I see now that it will need to cover some object-oriented programming. See the questions below for samples.

  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. C++ uses name equivalence of types defined using typedef.

    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.

    7. A dispatcher is part of the implementation of an object-oriented programming language that is responsible for finding functions that are associated with objects.

  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) = left(tail(x))? Use type variables. Function left takes the left-hand member of an ordered pair.

  4. What is the most general polymorphic type of the Astarte function select? Remember that select f L returns the first member x of list L such that f(x) is true. Also remember that select f L is parenthesized ((select f) L).

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