[Skip Navigation] [CSUSB] / [CNS] / [Comp Sci & Eng Dept] / [R J Botting] /[CS320 Course Materials] /06q.html [06q.txt(Text)] [Search ]
Thu Apr 23 12:16:43 PDT 2009
[Schedule] [Syllabi] [Text] [Labs] [Projects] [Resources] [Grading] [Contact]
Notes: [01] [02] [03] [04] [05] [06] [07] [08] [09] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20]

Contents


    CS320/06 Questions on Chapter 5

      Question 1

      1a. Give short definitions of each of the following: reserved word, keyword, case sensitive, binding, binding time, static binding, dynamic binding, lifetime, and scope.

      1b. Draw a diagram using the UML that shows a binding between a Variable and its Type.

      Question 2

      2a. What are: coercion, type checking, strong typing, and type compatibility?

      2b. Describe the good and bad points of strong typing .

      Question 3

      3a. Define static scoping and dynamic scoping.

      3b. What does this C++ program output:

       	#include <iostream>
       	using namespace std;
       	int i =1;
       	void f(int n){ cout <<n <<": "<< i; }
       	int main()
       	{  int i=2;
       	   f(3);
       	}

      Fill in the blank: This output shows that C++ functions use ____________ scoping.

      3c. What does this C++ program output:

       	#include <iostream>
       	using namespace std;
       	int i =1;
       	#define f(n) {cout <<n <<": "<< i;}
       	int main()
       	{  int i=2;
       	   f(3);
       	}

      Fill in the blank: This output shows that a C++ macro (#define) uses ____________ scoping.

      3d. Compare the advantages and disadvantages of these two scoping methods.

      Question 4

      Storage bindings. In C++ how do you create the following types of storage:
      1. a. static storage that holds one int
      2. b. stack-dynamic storage that holds one int
      3. c. explicit heap-dynamic storage that holds one int

      How are following kinds of storage in C++ deallocated?

      1. d. stack-dynamic storage
      2. e. explicit heap-dynamic storage

      Project

      You are designing a new language. You must decide (and justify) the issues and options raised in this chapter on names. Will your language be sensitive to case? (why?). Will you have reserved words or key words? (Why?) What is the scope of a variable? Will it be resolved statically or dynamically? (WHY!)

      Answers

      Answers to questions 1, 2, and 4 should be checked against the book. Check 3 online and in the book.

End