Computer Science 3675
Fall 2015
Practice Questions for Quiz 7

  1. What is one important motivation for including exception handling in a programming language?

    Answer

  2. How is exception handling implemented in a typical language, such as Java?

    Answer

  3. Are backtracking and exception handling the same thing? For example, can you use the exception handling mechanism of Java to do backtracking?

    Answer

  4. Using backtracking, write a Cinnameg program fragment that will print all solutions (x,y) to equation xy − 2x2 + y = 10, where x and y are both integers in the range 0,...,100. Do not use a loop or recursion. The program should have a straight-line look to it. That is, it has the look of a sequence of a fixed number of steps.

    Answer

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

    Answer

  6. What is shadowing, and how can it occur? Give an example.

    Answer

  7. Why is it important for a module to be able to control what it exports? Why not just export everything in the module?

    Answer

  8. How many lines does the following Cinnameg program fragment print? (Expression each(lst) backtracks, producing one branch for each member of lst. The Displayln statement prints one line each time it is run.)

        Try
          !x = each ["a", "b", "c", "d", "e", "f"].
          !y = each ["n", "o", "p", "q", "r", "s"].
          Displayln (x, y).
          Ensure false.
        %Try
    

    Answer