CSC 8310 Midterm Exam
Fall 2000, Villanova University
David Matuszek
Name ____________________________________

Please keep all answers short and to the point, and don't provide any information that wasn't asked for. There are no essay questions on this exam.

Prolog

  1. (20 points) Unification is an essential operation in Prolog. For each of the following, tell (1) whether the two expressions can be unified, and (2) if so, what is the value of each variable after unification.

    1. Able = Baker


    2. mother(Bill) = mother(Sally)


    3. loves(john, mary) = loves(mary, john)


    4. husband(John, Mary) = wife(Mary, John)


    5. spouse(John, Mary) = spouse(father(Bill), mother(Bill))


    6. father(mother(bill)) = father(Jane)


    7. child(Mary, mother(Bill)) = child(child(Bill), Mary)


    8. child(child(Sally), mother(Bill)) = child(child(John), Sally)


    9. Mary = mother(child(Mary))


    10. loves(john, _) = loves(_, mary)



  2. (15 points) Assume you have a Prolog database consisting of a large number of clauses of the following two predicates:

      son(Son, Mother, Father).            /* Example: son(bill, mary, john). */
      daughter(Daughter, Mother, Father).  /* Example: daughter(sally, mary, john). */

    Write the following predicates. Each predicate should require not more than three clauses.

    female(X)





    mate(X, Y) /* X and Y are parents of some child */






    childless(X) /* X has no children */






    different(X, Y) /* X and Y are not the same */






    siblings(X, Y) /* X and Y are different people with at least one parent in common */








Java

  1. (3 points) What is the difference between a class variable (also known as a static variable) and an instance variable?



  2. (6 points) Assume:
            class B extends class A;
            class C extends class A;
            A a; B b; C c;

    For each of the following assignment statements, put a checkmark by the statement if it is legal, correct it if it can be made legal, or cross it out if it is illegal and can't be fixed.

    a = b;

    b = c;


    c = a;


  3. (2 points) Where does Java require you to use a try...catch statement?





  4. (2 points) What is javadoc?




  5. (3 points) Arrange the following in order, from most general to least general: Applet, Component, Container, Object, Panel.




  6. (3 points) The main method of a class has a very specific form that you were asked to memorize. Write a main method with an empty body (that is, use {} for the body).




  7. (3 points) In Java, are parameters passed by reference or by value?




  8. (2 points) Name one thing that a Java application can do but a Java applet cannot do.



  9. (3 points) Name (don't describe, just name) the three parameters required in an <applet> tag.



  10. (2 points) Name two kinds of layout manager.



  11. (3 points) Java does not have multiple inheritance, but it does have a feature that partially makes up for the lack of multiple inheritance. What is that feature?


  12. (5 points) There have been four versions of Java so far: 1.0, 1.1, 1.2, and 1.3.

    1. The name "Java 2" refers to which version(s)?

    2. Which version(s) introduced new syntax?

    3. Which version(s) support the AWT?

    4. Which version(s) support Swing?

    5. Which version(s) include Swing?


  13. (6 points) Give a brief definition for each of the following terms:

    1. constructor



    2. getter



    3. sandbox




General

  1. (4 points) Give two differences between a function and a procedure.






  2. (5 points) Write a BNF definition for <ynum>, where a <ynum> is a four-digit integer in the range 0000 to 3000, inclusive. Assume that <digit> has already been defined.










  3. (6 points) Give a brief definition for each of the following terms:

    1. metalanguage



    2. turnstile



    3. scope (of a variable)




  4. (2 points) What does "ADT" stand for?


  5. (2 points) What does "GUI" stand for?


  6. (3 points) In a well-designed programming language, should parameters to a function be passed by value or by reference? Very briefly, state one reason for your answer.