Computer Science 3675
Practice questions for quiz 5
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.
Programs written in an object-oriented style tend
to be organized significantly differently from programs written
in a functional or procedural style.
Suppose that programs A and B do the same
thing, but A is written in a procedural style, and B
is written in an object-oriented style.
Changes to program A that would require
making modifications to existing functions might well be possible
in B almost entirely without modifying existing function
definitions.
In Java, a concrete class can have virtual
functions in it.
In Java, an interface can only contain virtual (or abstract)
functions, and cannot contain any instance variables.
In a single inheritance language, each class can
have at most one base class.
In object-oriented programming, an object's private variables
are only directly accessible to that one object.
In object-oriented programming, a protected data field
can only be used inside the definition of one class.
In Java, a class can implement more than one interface.
When unification binds a variable, it always binds that
variable to some constant.
Unification is symmetric. Unifying A and B has
exactly the same effect as unifying B and A .
When a variable occurs in a logic programming goal, the
interpreter is being asked whether that goal holds for all
values of the variable.
In logic programming, a variable in an axiom might be used as an
input variable sometimes, and as an output variable at
other times, when computation uses that axiom.
Cuts are used to reduce memory requirements and to
speed up computation.
Backtracking
is supported by almost all programming languages.
is not supported directly by any programming
languages, but must be simulated using recursion.
is supported by some programming languages, but is rarely
used in languages that support it.
is a control structure that involves trying more than
one answer to an expression or statement.
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?
In a logic programming style, write axioms for computing
predicate allsame(X), which is true just when all members of list
X are the same. For example, allsame([5,5,5]) is true,
as is allsame([a,a]), but allsame([2,4,4]) is false.
Note that allsame([]) is true, and allsame([b]) is true.
Show the logic programming search tree for goal
(member(X,[3,4,5]), member(X,[4])), up to the point where
a success is found. The definition of the member predicate is as follows.