Next: About this document
Computer Science 3675
Summer 2000
Quiz 4
- 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.
- A genuinely strongly typed language such as
Standard ML does not need to perform any type checking at
run time.
- Most object-oriented programming languages are
strongly typed.
- All programming languages employ types at compile time.
- Polymorphism is most useful in creating general
purpose libraries.
- Object-based programming is centered around the
notion of a class.
- Under the name equivalance rule, two types with
different names must be different types.
- An implementation of a typeless language does not
do any type checking at all, at compile time or run time.
- What is the most general polymorphic type of
function f defined by f(x) = tail(left(x))?
Function tail takes the tail of a list, and left takes the
left-hand member of an ordered pair.
Use and as type variables.
Answer:
- Function filter is defined so that (filter p x)
returns the list of all members of list x that cause
predicate p to return true. For example, suppose that
function pos is defined so that pos(n) is true just when n
is positive. Then (filter pos [9,-3,8,-2]) = [9,8].
Notice that (filter pos) is a function. What is the most general
polymorphic type of filter? Use and as
type variables.
Answer:
- Explain how variable selectors are inherited in
single-inheritance object-oriented programming languages.
Karl Abrahamson
Mon Jun 19 13:40:17 EDT 2000