Given the following Algol program, show the results produced by running the program under each of the following parameter passing mechanisms. Assume that print is an output statement that writes the value of each of its parameters, separated by one or more spaces.
begin
integer i;
integer array A[1:2];
procedure pass ( x, y );
integer x, y;
begin
y := x;
x := 1
end
i := 1;
A[1] := 2; A[2] := 3;
pass (A[i], i);
print (i, A[1], A[2])
end
What sequence of values will be printed by the following Algol code segment? Assume that print writes the value of its parameter followed by a space, and that variable x currently has the value 4.
for i := 8, 10,
12 step -3 until 6,
if x < i then 16 else x,
i / 2 while i >= x
do print( i )
How is aliasing possible in Pascal, and how can it be used to subvert the type system?
What is the difference between subtypes and derived types in Ada?
What is the difference between packages and tasks in Ada?
What is the scoping rule for exceptions in Ada? Why?
Which language(s) use(s)
When is a static local (in Algol, an own) variable initialized? Reinitialized?
Why is the private part of an Ada package specification made visible?
Which link -- static or dynamic -- points to the AR of a procedure's caller?
Does Ada use structural or name equivalence for type checking?
What does a begin-end pair define in Pascal?
Where are local variables typically stored -- heap or stack?
What is the difference between independent compilation (as in FORTRAN) and separate compilation (as in Ada)? What is the disadvantage of the first method? What is required to perform the second?
Is it possible for a compiler to know the amount of space needed for executing a FORTRAN program? An Algol program? What features of each language make it possible or impossible?
A certain Ada program requires a list of stacks, some of which must hold integers, and others which are to hold characters. The list must be implemented as a linked list (using the access type), since the number of stacks required is not known at compile time. Should these stacks be implemented using internal or external representations of the abstract data type? Why?
What is the difference between a generic package in Ada and an object in Java?
What is the advantage of polymorphism in Smalltalk compared with procedural overloading in Ada?
What is the closed-world assumption and how does it affect the execution of a Prolog program?
Given the following Prolog facts and rules
parent ( a, b ). parent ( a, c ). parent ( b, d ). parent ( b, e ). parent ( c, f ). parent ( f, g ). parent ( f, h ). parent ( f, i ). ancestor ( X, Y ) :- parent ( X, Y ). ancestor ( X, Y ) :- parent ( Z, Y ), ancestor ( X, Z ).
show the output which will be printed in response to the query
?- ancestor ( U, h ).
Assume the user prompts for all possible responses.
Assume the following clauses are in a Prolog database:
p( h( a, X ), f( b, Y )). q( Y, Y, Y, h( a, (h( b, Y ))). r( f( X ), g( Y ), Z ). s( f( X ), g( X ), X ). t( Y, a ). u( v( X, X )).
Determine whether each of the following queries is unifieable with some fact in the database; if so, give a unifier.
Parenthesize the following expression and number each parenthesized portion to show the order in which messages would be sent according to Smalltalk's precedence rules.
OrderedCollection new at: x put: y + 2 * z factorial