CSE 413

Quiz #7 with answers

5/23/97

Closed book, closed pencil (to start, anyway)

Perfect score 17


Is there any difference between an enumeration type and a subrange type (yes or no)? yes

What type constructor corresponds to the mathematical concept of a Cartesian product? record (structure)

Given an example of two variables which would be type equivalent under structural equivalence, but not under name equivalence. Circle the language you are using: C, Pascal, Ada.

typedef struct {double x,y} s1;

typedef struct {double a,b} s2;

s1 v1; s2 v2;

v1 and v2 are are structurally equivalent but not name equivalent.

Given an example of an implicit (or anonymous) type. Circle the language you are using: C, Pascal, Ada.

int a[10];

(a is of type "array of integers of size 10"; there is no identifier (type name) for that type.)

True or False: coercion is one form of explicit type conversion. (Should be "implicit.")

Name one way that the semantics (not syntax) of Dijkstra's "guarded do" command differs from the cond of LISP. cond conditions are checked in order; D's guards are checked nondeterministically. Actually an error in the question -- it was intended to ask about the "guarded if" rather than the "guarded do."

Some people use the term "parameter" to mean "formal parameter" and "argument" to mean "actual parameter".

Some languages distinguish between "procedures" and "functions." Briefly, what is the difference?

Procedures don't return values.

When is an activation record created? When the block (function, procedure, etc.) is invoked.

Which of the following are likely to be found in an activation record (circle): global variables, local variables, source code, executable code, return addresses, links to other activation records, access chain, symbol table, parameter values, parameter types.

Our book mentions 4 kinds of parameters passing. Name them:

  1. pass by value
  2. pass by reference
  3. pass by value-result
  4. pass by name

What is meant by an "exception" (in the context of programming languages)? An unexpected event at run-time.

As a control mechanism, is exception handling considered to be explicit or implicit?

Name a programming language which DOES have an exception handling mechanism.

Basic, PL/I, C++, Ada, Java, Clu

Name a programming language which DOES NOT have an exception handling mechanism.

Pascal, C, COBOL, Fortran, Modula-2, LISP, etc. (At least in their standard versions. Sometimes there are experimental dialects which have E.H.)