Actual Exam from Credible Source with 105
Questions and 100% Verified Detailed Correct
Answers Guaranteed
<assign> -> <var> = <expression>
Define the LHS and RHS
ref ch3 - CORRECT ANSWER: LHS of arrow (->) is the abstraction being defined
RHS of arrow (->) is the definition of the LHS.
RHS consists of some mixture of tokens, lexemes, and references to other abstractions.
(Tokens are also abstractions)
A simple subprogram consists of two separate parts:
ref ch 10 - CORRECT ANSWER: The actual code of the subprogram, which is a
constant
The local variables and data listed previously which can change when the subprogram
is executed.
in the case of simple subprograms, both of these parts have fixed sizes.
A variable whose lifetime is that of a whole program is said to have "__________"
ref ch 9 - CORRECT ANSWER: unlimited extent -- this usually means they must be
heap dynamic rather than stack dynamic
,Calculate the precondition for 2 and 3 iterations of the loop. Generalize your answer.
while y <> x do
y=y+1
end
{y = x}
One Iteration:
wp(y = y + 1, {y = x}) {y = x - 1} - CORRECT ANSWER: Second Iteration:
wp(y = y + 1, {y = x -1} ) = { y + 1 = x - 1 }
or { y = x - 2}
Third Iteration:
wp( y = y + 1, { y = x - 2} ) = { y + 1 = x - 2 }
or { y = x - 3}
It is obvious that { y < x } will suffice for cases of one or more iterations, combining with {
y = x } for the zero iterations case we get { y <= x } which can be used as the loop
invariant.
The precondition for the while statement can be determined from the loop invariant.
For example
{y <= x and y <> x} y = y + 1 {y <= x}
Applying the assignment axiom to
y = y + 1 {y <= x}
we get {y + 1 <= x}, which is equivalent to {y < x}, which is implied by {y <= x and y <>
x}. So, the earlier statement is proven
, Can a wildcard be restricted?
ref ch 9 - CORRECT ANSWER: Yes -- as is the case with nonwildcard types. Such
types are called bounded wildcard types.
ie
Collection <?> c = new ArrayList();
//another example
public void drawAll(ArrayList<?> extends Shape> things)
The generic type here is a wildcard type that is a subclass of the Shape class.
This method could be written to draw any object whose type is a subclass of Shape.
Can nonterminal symbols have two or more distinct definitions representing two or more
possible syntactic forms in the language?
ref ch 3 - CORRECT ANSWER: Yes. Multiple definitions can be written as a single rule,
with the different definitions separated by the symbol.
Compute the conditions across branches
if x > 0 then
y=y-1
else
y=y+1
{y > 0}
ref lec slides Axiomatic Semantics Pt2 - CORRECT ANSWER: First the "then" clause:
y = y - 1 {y > 0}