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.
- 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.
- In a typeless language, all type checking done at
run time.
- Standard ML is a strongly typed language.
Therefore, in Standard ML, it is not
possible to get a type error at run time.
- Polymorphism is most useful in designing custom applications,
and is rarely used in function libraries.
- C++ uses name equivalence of types defined using typedef.
- The class is an important concept of object-based programming.
- In most object-oriented languages, some type checking
must be done at run time.
- A dispatcher is part of the implementation of an
object-oriented programming language that is responsible for finding
functions that are associated with objects.
- 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.
- 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.
- 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).
- 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?