----------------------------------------------------------------------------
COP 3610 -- EXAM 2 -- 60 POINTS MAX	PRACTICE COPY	M. Schmalz   010403
----------------------------------------------------------------------------

    *** YOU MAY USE A TWO-SIDED 8-1/2" x 11" CRIB SHEET FOR THIS EXAM ***
	    *** ALL OTHER BOOKS AND NOTES MUST BE PUT AWAY ***
          *** ANSWER ALL QUESTIONS - NO PENALTY FOR GUESSING ***

  NAME:_______________________________________	SSN: _______________________

  ANSWER EACH QUESTION WITH THE "BEST" ANSWER.  PUT ANSWERS IN BLANKS
	NOTE:  More than one answer may be true.  Choose carefully.

8pts    1) What does each of the following commands do?  (Consider each step)

         cc p1.c p2.c end.c -o p12e      1) _Compile p1,p2,end 

					 2) _Link p1,p2,end => obj.file p12e

         ls -a | cat litter.box          1) _List all files in current directory

					 2) _Put file listing in file litter.box

11pts   2) What are three commands that use Regular Expressions - give  
           a nontrivial example of each command.

         fgrep test *[^1234].*m   -- find string "test" in files whose
	        names contain any character except 1,2,3, or 4 and end with
		an "m"

         more *kim* -- pagewise display of all files in current directory
                whose names contain the string "kim"

         ls -la Cybix[12345] -- list detailed attributes of all files
                that have names beginning with "Cybix" followed by a 1,
		2,3,4, or 5


9pts	3) Match the letters with the UNIX commands or constructs:

__R___  cc    		a) object code transformation	j) Java compiler  

__G___	man | more	b) Gershenson C compiler   	k) Java debugger

__J___  javac 		c) start the Korn shell		l) link object files 

__R___	f77   		d) show directory pagewise	m) text editor 

__G___	less  		e) C compiler       		n) C++ compiler      

__Q___	java 		f) 1977 Fournier shell         	o) show Text files

__L___  ld            	g) pagewise documentation 	p) show file pagewise

__M___ 	emacs    	h) invokes Java-C linker	q) Java runtime module

_E,N__	gcc   		i) illegal UNIX command		r) none of above

_A,C__  4) A regular expression in UNIX:

2pts	a) is a string of symbols that organizes text	b) compiles commands
	c) constrains the functionality of a UNIX program or command
	d) links user data with a UNIX application	e) runs UNIX code

    NOTE:  The best answer is C, but A is also acceptable since
              we discussed that in class.




----------------------------------------------------------------------------
COP 3610 -- EXAM 2					M. Schmalz  page 2/2
----------------------------------------------------------------------------

6pts  5) List three advantages and three disadvantages of the Java language:

                      ADVANTAGE                      DISADVANTAGE

         #1     _Structured hi-level lang.  __Limited polymorphism_______


         #2     _Object-oriented________    __No multiple inheritance____


         #3     _Machine-independent____    __Bytecodes usually need to be
                                              recompiled for version con-
					      sistency.


6pts  6) What is object-oriented programming, and why is it important in UNIX?

        Object oriented programming involves the partitioning of a
           program into classes and methods.  A class and its subclasses
           specify a hierarchy of objects, which are operated on by the
           methods.  OOP supports encapsulation, polymorphism, and
           inheritance, which in turn support distributed computation
           better than traditional languages such as C.  Distributed
           computation supports implementation of network-based
           (distributed) computing paradigms, which are supported by
	   UNIX design philosophy and implementations (e.g., Remote
	   Procedure Calls, sockets, and other communication devices).


      Given the following UNIX response to the "ls" command, answer each
      of the questions below, ASSUMING THAT EACH LISTED COMMAND IS INDEP-
      ENDENT OF THE OTHER COMMANDS.  If an erroneous command, state that.

	Zimbabwe.html   Tortugas.html  Cdfkj2347.html  Zimbabwe.txt
        America.txt     Galapagos.htm  Cdfkp2337.htm   Zephyrhills.txtl
        America.tx2     Galasales.htm  Cddkp2547.htm   Zephyrwinds.txt
	
3pts  8) How many filenames displayed for:

         ls -l Z*.*t*            ===>   __2: Zimbabwe.*__________________

3pts  9) What filenames displayed for:

         ls C*[2357]*m           ===>   __Cdfkp2337.htm, Cddkp2547.htm___

2pts 10) How many filenames displayed for:

         ls [GCZ]*3*.t*          ===>   __2: Cdfkj2347.html,Cdfkp2337.htm

5pts 11) Given the command:  cc p1.c p2.c -o snap , list two ways this
         could be expressed correctly in a makefile:
         
         #1: __cc p1.c p2.c -o snap _____________________________________
  

         #2: __cc p1.c -o p ; cc p2.c -o q ; snap: p q __________________

5pts 12) What are variables used for in makefiles?  Give one example.

        Variables in any programming language are used to represent
              abstractions or more complex structures.  In makefiles,
              variables store information that might, for example, be
              a long pathname to a directory or file.  Instead of
              typing the pathname, you can just use the variable name.

              Ex.1:   PATH = /cis/homes/bsimpson/source/Proj1
                      cc ${PATH}/p1.c -o p1

              Ex.2:   COMPILER = cc

	              ${COMPILER} f1.c f2.c - o o3


-EOF-