- | P a g e
CS 326 FINAL EXAM AND STUDYGUIDE
NEWEST ACTUAL EXAM COMPLETE 200
QUESTIONS AND CORRECT DETAILED
ANSWERS (VERIFIED ANSWERS) |ALREADY
GRADED A+||BRAND NEW!!
- Type coercion is an explicit (specified by the programmer)
conversion from a value of one type to a value of another type.
THE CORRECT ANSWER: is False
- Displays allow accessing a non-local variable in constant
time, while static chains require dereferencing an arbitrary number of pointers.
THE CORRECT ANSWER: is True
- In C++, modifying headers of private member functions in a
class requires to recompile all files that use the class, but never to rewrite them.
THE CORRECT ANSWER: is False
- In C++, modifying headers of public member functions in a
class requires to recompile all files that use the class, but never to rewrite them.
THE CORRECT ANSWER: is False
- | P a g e
- Unlike macros, inline functions in C++, use applicative order
evaluation, type checking and scope rules.
THE CORRECT ANSWER: is True
- Prolog belongs to the class of declarative programming
languages.
THE CORRECT ANSWER: is True
- Dangling references in C can appear in the context of heap
allocation, but not in the context of stack allocation.
THE CORRECT ANSWER: is False
- In Java, an object (instance of a class) can be created only
dynamically, by using the new operator.
THE CORRECT ANSWER: is True
- What is a Java Virtual Machine?
THE CORRECT ANSWER: is Any computer platform with
the Java interpreter specific to that platform
- C does NOT include static links in its stack activation
frames because:
- | P a g e
THE CORRECT ANSWER: is It uses static scoping
- Which of the following is NOT a key characteristic of
object-oriented programming?
THE CORRECT ANSWER: is Dynamic Scoping
- What is the scope of a variable in a Prolog rule?
THE CORRECT ANSWER: is Local to the rule and all
instances of the variable within the rule must unify
- Assume two version of the same program - one using
macros, and the other using functions. In general, which one will run faster? Which one will produce a larger compiler- generated code? Why?
THE CORRECT ANSWER: is Macros will run faster,
however functions will create more compiler code. This occurs because Macros do not check for compilation errors and thus execute faster. Along with this, Macros are preprocessed meaning they are processed before compile time where functions are compiled
- In most languages, local variables are allocated dynamically
on the stack, thus introducing a run-time overhead caused by stack maintenance operations. Why not just reserve a memory
- | P a g e
region for each subroutine's local variables, and allocate them statically there?
THE CORRECT ANSWER: is If we reserve space in
memory for subroutine calls, there will be very little data needing allocation which will cause wasted memory. On the other hand, if there is too much data and not enough allocation, there will be a fault in the program
- As a garbage collection algorithm, reference counting does
not handle circular lists properly. Why? What makes the mark- and-sweep algorithm better for dealing with circular lists?
THE CORRECT ANSWER: is
- L -> a
L -> [ ] L -> [ L M ] M -> , L M M -> | L M -> ε Show a parse tree for [a,a|[a]].
THE CORRECT ANSWER: is
- What are discrete types?