Programming Languages
Mid-Term Exam
Sample Questions

1.  Give an example of a program fragment in any language that contains an explicit heap-dynamic variable.  Clearly indicate which variable in the program is explicit heap-dynamic.

2.  Give an example of a program fragment in any language that contains an implicit heap-dynamic variable.  Clearly indicate which variable in the program is implicit heap-dynamic.

3.   Give an example of a program fragment (in a programming language of your choice) in which the same name is used to describe two different variables.

4.  Two factors in programming language design which can affect reliability are exception handling and aliasing.  Explain how each of these two factors affect reliability, and clearly indicate in each case whether the effect is positive or negative.

5.   Consider this program:

procedure Example is
		X: Integer;

	procedure First is
	begin
		Put(X);			-- Print X
		New_Line;		-- Print a newline character
	end First;

	procedure Second is
		X: integer;

		procedure Third is
			X: Integer;
		begin -- Third
			x := 99;
			First;
		end Third;

	begin -- Second
		x := 88;
		Third;
	end Second;

begin -- Example 
	x := 77;
	First;
	Second;
end Example;
a)  What will be printed by this program if we assume static scope?
b)  What will be printed by this program if we assume dynamic scope?
6. A simple loop in Ada has the following form:
        loop
                <statement>;
                <statement>;
                ...
                <statement>;
        end loop;
That is, it begins with the word loop, contains one or more statements (each followed by a semicolon), and ends with the words end loop. There must be at least one statement inside the loop.

a) Write a set of Extended Backus-Naur Form (EBNF) grammar rules that describe Ada simple loops. You may assume that <statement> has already been defined elsewhere.

b) Write a syntax diagram (syntax graph) that describes Ada simple loops. You may assume that <statement> has already been defined elsewhere.


Nancy Tinkham
Computer Science Department, Rowan University

Valid HTML 4.0!