• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 3 out of 25 pages
Exam (elaborations)

Cse 340 Exam Prep Questions With Answers And Explanations

Document preview thumbnail
Preview 3 out of 25 pages

Cse 340 Exam Prep Questions With Answers And Explanations

Content preview

CSE 340 EXAM PREP QUESTIONS WITH
ANSWERS AND EXPLANATIONS
Question 1. Which option correctly resolves this preparation scenario: explain what a
module interface provides to clients? The decision should be made while keeping the
phase responsibilities clear.
A. A module interface specifies what names or operations are exported without requiring
clients to know
the implementation details.
B. A module interface lists only private memory addresses used at runtime.
C. A module interface is a parser stack used during compilation.
D. A module interface forces all clients to use the module source text directly.
Correct Answer: A. A module interface specifies what names or operations are exported without
requiring clients to know the implementation details.
Explanation: Module interfaces support information hiding and separate compilation.
Question 2. For exam preparation, consider a static analyzer that must characterize
dynamic type checking. Which answer should you be ready to justify?
A. All variables must have one compile-time type that can never vary.
B. Type information is unnecessary at runtime because no operations are checked.
C. Dynamic typing means dynamic memory allocation and nothing more.
D. Type compatibility is determined using runtime value/type information during execution.
Correct Answer: D. Type compatibility is determined using runtime value/type information during
execution.
Explanation: Dynamically typed languages attach type information to values and check
operations as they
execute.
Question 3. A readiness check asks how to state how solved type-variable bindings
should affect remaining constraints. Which choice reflects the core rule? Focus on the
rule associated with substitution application, not on an unrelated implementation detail.
A. Apply the substitution only to the first occurrence and leave the rest unchanged.
B. Apply substitutions to source whitespace rather than type expressions.
C. After solving a type variable binding, apply the substitution consistently throughout
remaining
constraints and inferred types.
D. Discard solved bindings before checking other constraints.
Correct Answer: C. After solving a type variable binding, apply the substitution consistently
throughout remaining constraints and inferred types.
Explanation: Consistent substitution propagation is necessary for a coherent unification result.
Question 4. To confirm mastery, imagine a programming-language toolchain that needs
to identify the data structure representing one active procedure call. What is the best
answer? The decision should be made without changing the intended program meaning.
A. An activation record stores per-call information such as parameters, locals, return address,
and
bookkeeping links.
B. An activation record is the parse tree for one procedure definition.
C. An activation record contains only heap objects that outlive the call.
D. An activation record is a lexical token table.
Correct Answer: A. An activation record stores per-call information such as parameters, locals,
return address, and bookkeeping links.
Explanation: Each active procedure call typically has a stack frame or activation record.

,Question 5. Which option correctly resolves this preparation scenario: identify how
lambda calculus can represent data without primitive data constructors?
A. Church encodings represent data such as booleans using only functions and application.
B. Church encodings require built-in machine Boolean values.
C. Church encodings depend on mutable heap cells for every value.
D. Church encodings are scanner rules for reserved words.
Correct Answer: A. Church encodings represent data such as booleans using only functions and
application.
Explanation: The lambda calculus can encode booleans, numerals, pairs, and control behavior
using functions
alone.
Question 6. For exam preparation, consider a programming-language toolchain that must
decide how ordinary comments and insignificant spaces should be treated by a scanner.
Which answer should you be ready to justify?
A. Convert all whitespace into arithmetic-operator tokens.
B. Discard or channel whitespace/comments unless the language makes them syntactically
significant.
C. Place comments directly into the parse tree as executable statements.
D. Reject any source file that contains characters not used by operators or identifiers.
Correct Answer: B. Discard or channel whitespace/comments unless the language makes them
syntactically significant.
Explanation: Scanners often remove trivia such as comments and insignificant whitespace before
parsing.
Question 7. A readiness check asks how to prepare a grammar for top-down predictive
parsing. Which choice reflects the core rule? The decision should be made while
maintaining a consistent implementation.
A. Introduce more immediate left recursion to guarantee termination.
B. Convert every terminal into a heap object before parsing.
C. Eliminate immediate left recursion before using a straightforward predictive
recursive-descent parser.
D. Replace FIRST sets with garbage-collection roots.
Correct Answer: C. Eliminate immediate left recursion before using a straightforward predictive
recursive-descent parser.
Explanation: A rule such as E -> E + T can cause naive recursive descent to recurse without
consuming input.
Question 8. To confirm mastery, imagine a optimizer pipeline that needs to distinguish
locations from computed values in assignment semantics. What is the best answer?
Focus on the rule associated with lvalue rvalue, not on an unrelated implementation
detail.
A. An lvalue is always a lexical token and an rvalue is always a parse tree.
B. An lvalue must be heap allocated and an rvalue must be stack allocated.
C. An lvalue is a type variable and an rvalue is a grammar nonterminal.
D. An lvalue designates a storage location, while an rvalue denotes a value used in an
expression.
Correct Answer: D. An lvalue designates a storage location, while an rvalue denotes a value used
in an expression.
Explanation: Assignment normally requires a modifiable location on the left and a computed
value on the right.

, Question 9. Which option correctly resolves this preparation scenario: identify the
defining software-abstraction property of an ADT?
A. An abstract data type exposes operations and behavior while hiding representation details
behind an
abstraction boundary.
B. An abstract data type requires clients to manipulate its representation fields directly.
C. An abstract data type is merely a token category recognized by the scanner.
D. An abstract data type eliminates the need for any runtime values.
Correct Answer: A. An abstract data type exposes operations and behavior while hiding
representation details behind an abstraction boundary.
Explanation: ADTs separate what operations mean from how their internal representation is
implemented.
Question 10. For exam preparation, consider a static analyzer that must apply the basic
substitutability idea behind subtyping. Which answer should you be ready to justify? The
decision should be made without relying on hidden runtime guesses.
A. A supertype value can always be used where any subtype is required without restriction.
B. A subtype value may be used where a supertype value is expected when the language
defines a valid
substitutability relation.
C. Subtyping means two types have identical names.
D. Subtyping is simply implicit numeric widening.
Correct Answer: B. A subtype value may be used where a supertype value is expected when the
language defines a valid substitutability relation.
Explanation: Subtyping supports safe substitution under the rules of the type system.
Question 11. A readiness check asks how to diagnose an unsatisfiable type-equality
constraint. Which choice reflects the core rule?
A. Silently rename Bool to Int and continue.
B. Allocate both types on the heap and treat the addresses as equal.
C. Resolve the conflict by choosing whichever type name is shorter.
D. Report a type error when constraints require incompatible constructors, such as equating
Int with Bool.
Correct Answer: D. Report a type error when constraints require incompatible constructors, such
as equating Int with Bool.
Explanation: Unification fails when rigid type constructors disagree.
Question 12. To confirm mastery, imagine a programming-language toolchain that needs
to state a key limitation of reference counting. What is the best answer?
A. Reclaim an object when its reference count reaches zero, but recognize that unreachable
cycles can
remain unreclaimed.
B. Reference counting always collects cycles automatically with no additional mechanism.
C. Reference counting requires tracing the entire heap from roots before every decrement.
D. Reference counting is performed only by the parser.
Correct Answer: A. Reclaim an object when its reference count reaches zero, but recognize that
unreachable cycles can remain unreclaimed.
Explanation: Simple reference counting cannot by itself detect some cyclic garbage.

Document information

Uploaded on
October 10, 2026
Number of pages
25
Written in
2026/2027
Type
Exam (elaborations)
Contains
Questions & answers
$15.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Favorgrades
3.8
(199)
Sold
854
Followers
377
Items
57829
Last sold
1 week ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions