next up previous
Next: About this document

Computer Science 3675
Summer 2000
Quiz 5

  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. Programs written in an object-oriented style are generally organized according to types of data, while programs written in a procedural style are generally organized according to types of functions.
    2. In Java, an abstract class is a class that contains at least one virtual function.
    3. In Java, an interface can only contain virtual (or abstract) functions, and cannot contain any instance variables.
    4. Java allows multiple inheritance from classes.
    5. In Java, a class can implement more than one interface.
  2. Unification is a form of pattern matching. Which of the following is not a characteristic of unification?
    1. Unification never changes the binding of a bound variable.
    2. Unification is symmetric; unifying A with B has exactly the same effect as unifying B with A.
    3. Unification is very slow, and is only used rarely during computations of logic programs.
    4. Unification can bind unbound variables.
  3. A cut in a backtracking program
    1. Removes backtrack control frames from the control stack.
    2. Adds a backtrack control frame to the control stack.
    3. Never succeeds when tried.
    4. Usually has very little effect on how a program runs.
  4. In a logic programming goal, unbound variables
    1. are not allowed, since a goal must only produce true or false.
    2. must remain unbound after the goal has been processed.
    3. are implicitly universally quantified, with the system asked to prove the goal for all values of the variables.
    4. are implicitly existentially quantified, with the system asked to find some values that satisfy the desired conditions.
  5. Suppose that you know a list Y and a value A. Using only the append predicate, list notation and the :: operator, write a goal containing variables Y and A that is satisfied just when Y is nonempty and the last member of list Y is A. Do not define any new predicates for this.
  6. Write logic programming axioms (Horn clauses) that define a predicate called allAre so that allAre(X,A) is true just when X is a list all of whose members are A. For example, allAre([3,3,3,3],3) is true, and allAre([a,a],a) is true, but allAre([b,a], a) is false. Note that allAre( tex2html_wrap_inline54 ,2) is true.
  7. When an exception happens during execution of a program, the exception manager must begin forcing functions to return, and removing their frames from the run-time stack. How does the exception manager know when to stop removing frames?



next up previous
Next: About this document

Karl Abrahamson
Mon Jun 19 13:32:40 EDT 2000