REVIEW FOR FINAL:

Topics from text we covered this semester and may be covered on final exam (You are also responsible for topics covered by class slides and other material covered in lecture and recitations.)

* -- Topics with an asterisk have an extremely high probability of appearing on the final. Other items may also be on final.

Chapter 1 -- Introduction

Chapter 2 -- Language design issues

Chapter 3 -- Language translation issues

Chapter 4 -- Data types

Chapter 5 -- Encapsulation and memory management

Chapter 6 -- Sequence control

Chapter 7 -- Subprograms

Chapter 8 – Inheritance

Chapter 9 -- Other topics

Languages:

 

Test questions will be similar to questions in: (1) your previous exams, (2) your homeworks, and (3) the sample questions below. The questions on the final may not be identical to any previously given questions but they will be similar in content.

SAMPLE QUESTIONS:

  1. C supports only one parameter passing mechanism, what is it?
  2. How is pass-by-reference simulated in C?
  3. When do pass-by-name and pass-by-reference differ? There will be a section of code in which you will need to determine the difference.
  4. When do pass-by-reference and pass-by-value-result differ? There will be a section of code in which you will need to determine the difference.
  5. Which of the following languages support pass-by-reference? Which support pass-by-name?
    • C
    • C++
    • Pascal
    • ALGOL
  6. What is a Display vector, and what is the max number of memory accesses needed to retrieve and non-local variable when a Display vector is used?
  7. What information is stored in a display vector?
  8. What information is stored in an activation record, list specific items.
  9. True or False, when static scoping is used, activation records must contain an environment table listing the names and values of all local variables.
  10. What is the "lifetime" of a variable. What is the "scope" of a variable. Give examples of when they are different?
  11. In general, statically declared variables are stored in the _________, and dynamically declared variables are stored in the __________.
  12. In C++, a call to "new()" is made for what purpose?
  13. Is "fragmentation" a problem when variables are stored on the run-time stack?
  14. How are "reference counts" used in memory management?
  15. In the two-stage garbage collection algorithm referred to as "mark and sweep", explain what happens in both the mark stage and the sweep stage.
  16. Name 2 languages that allow some form of "unification"?
  17. What are the problems associated with recovery of variable-sized memory blocks in garbage collection.
  18. True or False, in developing the first programming languages, the main concern was efficient utilization of machine resources and not ease of use by the programmer.
  19. True or False, the earliest programming languages (before Fortran and Cobol) were compiled not interpreted.
  20. True or False, the first programming language to use the concept of "block structure" was Fortran.
  21. True or False, in block structured languages, parameter transmission is typically implemented using the run-time stack.
  22. True or False, the ordering of symbols within a program is described by context-free grammars.
  23. True or False, the tokens of a programming language are such things as keywords and identifiers. When parsing a program, the ordering of the symbols within a token are described by context-free grammars.
  24. True or False, context-free grammars are sufficient to describe all programming language constructs.
  25. True or False, Prolog is a functional programming language.
  26. The theoretical computational power of C++, prolog, lisp, and Ada are all equivalent.
  27. In C++ all objects are stored on the heap.
  28. Define reference parameter.
  29. Define syntax and semantics.
  30. Define binding and binding time.
  31. Define lifetime and scope.
  32. Define static scope and dynamic scope.
  33. Define dynamic type binding and static type binding.
  34. Define weakest pre-condition.
  35. The following are Smalltalk messages. In each case, identify the object receiving the message.
  36. What is the purpose of the keyword virtual in C++?
  37. What is the minimum machine capable of recognizing a regular language?
  38. What is the minimum machine capable of recognizing a context-free language?
  39. Below is a set of grammar rules. With respect to the Chomsky hierarchy, what kind of grammar is this
  40. Describe the difference between a Finite State Automata and a Pushdown Automata.
  41. How does C++ support encapsulation?
  42. How does Ada support encapsulation?
  43. Identify the programming language used in each of the statements below (each statement may be written in a different programming language):
  44. Draw the structure for the following Lisp expression:
  45. Specify an automata to recognize {ab*a}.
  46. Write a egrep regular expression to find all lines containing the expression Fred or Frederic G. Majors.
  47. Show the parse tree for a top-down parse of the following sentence using the grammar specified below: The boy bounced the ball.

    S -> NP VP,

    NP -> N

    NP -> D N

    VP -> V

    VP -> V NP

    V -> ran | bounce | caught

    N -> cat | mouse | boy | girl | ball

    D -> the | a  

  48. Consider the following program in a language that allows for nested scope:
  49. procedure main 
      integer I; 
      integer A[0:4]; 
      for I=0 to 4 do A[I] = I; 
      I=1; 
      P(I,A[I]); 
      write(I,A[I]); 
    
      procedure P(integer A; integer B); 
        integer T; 
        A=A+1; 
        T=B+1; 
        I=I+1; 
        B=A+T; 
        write(A,B); 
      end P; 
    end main; 
     
    1. Assuming Call by Reference:
      1. What is printed for A?
      2. What is printed for B?
      3. What is printed for I?
      4. What is printed for A[I]?
    2. Assuming Call by Value­Result:
      1. What is printed for A?
      2. What is printed for B?
      3. What is printed for I?
      4. What is printed for A[I]?
    3. Assuming Call by Value:
      1. What is printed for A?
      2. What is printed for B?
      3. What is printed for I?
      4. What is printed for A[I]?
    4. Assuming Call by Name:
      1. What is printed for A?
      2. What is printed for B?
      3. What is printed for I?
      4. What is printed for A[I]?
  50. For the program above, assume the following addresses:
  51. Fill in the following values:

  52. Every activation record in C must contain:
  53. Which statements are true?
    1. C uses the mark­sweep algorithm to clean up the runtime heap.
    2. LISP, ML and Smalltalk all use automatic garbage collection.
    3. If C used reference counts, then dangling references would never occur.
    4. Tombstones are a method for compacting storage during garbage collection.
  54. Which statements are true?
    1. C activation records do not need dope vectors
    2. Smalltalk implements mixed inheritance
    3. Functional programming can be done in C
    4. Imperative programs can be written in Prolog
  55. Give the Postfix (a) and value (b) for the C­language expression 8 + 4/2 - 5
  56. What is printed by the following C program assuming write simply writes out the values:
  57. main()
    {
      union{ union {int A; real B} C; int D} E[4]; 
      E[1].C.A = 2; 
      E[1].C.B = 3; 
      E[1].D = 4; 
      write(E[1].C.A , E[1].D );
    }
    
    1. E[1].C.A
    2. E[1].D

     

  58. Consider the C++ program:
  59.  
    #include <stream.h> 
    class top {
       public: top() {a=1;}; 
       void newfcn() {local();}; 
       protected: int a; 
       virtual void local() {cout<<a<<endl;};
    }; 
    class bottom: public top {
       public: bottom() {a=2;}; 
       protected: void local() {cout<<a<<endl;};
    }; 
    main() {
       top x; 
       bottom y; 
       x.newfcn(); 
       y.newfcn();
    }
    
    1. What is printed for x.newfcn?
    2. What is printed for y.newfcn?
  60. In the program above, what happens if virtual were deleted in the above definition?
    1. What is printed for x.newfcn?
    2. What is printed for y.newfcn?