CMPS 350 HW 01: Introduction to Programming Languages

Click 'check' on each question or your score will not be recorded.

01. C pointers are non-orthogonal because a pointer is a primitive scalar type 
    that does not consistently behave like other scalars. The following lines 
    of code behave as expected if c and d are integers. Which lines behave 
    inconsistently if c and d are pointers (i.e., will cause a syntax error)? 

    A. c = d;     
    B. d++;                    
    C. c *= d; 
    D. c = c+d;  
A B C D
02. C parameters are passed by value. To pass an array you pass the value of 
    the array's address (i.e., a pointer) as type char * or char[]. This is 
    non-orthogonal because

    A. the name of the array is treated like an address.
    B. Index operators [] can be used on type char * and type char [].
    C. Both A and B are correct.
A B C
03. Assume you have a Student class in C++ that uses dynamic memory allocation 
    for the student's name:  char *name;  
 
    What happens after the following code is executed if the assignment operator
    in line 3 performs a bit copy? (i.e., '=' is not overloaded by programmer)

    Student One("Sam Spade");
    Student Two("Joe Smoo");
    One = Two;  // Line 3   
    strcpy(Two.name,"FooBar");   // copies "FooBar" to Two.name  

    A. Student.One and Student.Two are both named "FooBar"
    B. Student.One is named "FooBar" and Student.Two is named "Joe Smoo"
    C. It will cause a runtime error.
A B C
04. Which criterion for a good programming language is C most deficient in?

    A. efficiency    B. reliability    C. readability    D. writeability
A B C D
05. Which are true concerning C++'s exception handling facility?
    A. You can pass error codes back to the calling routine without using the
       return value.
    B. If objects are allocated in a try block, destructors are automatically
       called if an exception occurs.
    C. If an exception is caught in a function, the exception must be rethrown 
       back to the calling function.
    D. A try block must have a matching catch block.
A B C D
06. In C++ what happens to an unhandled exception?
    A. The exception is thrown to each function on the runtime stack in reverse
       call order. 
    B. The exception is rethrown to each function on the runtime stack in call
       order. 
    C. The program immediately terminates with an error message.
    D. There is no such thing as an unhandled exception.
A B C D
07. When would you not re-throw an exception back to the calling routine?
    A. If you want to handle a non-critical error locally.  
    B. If you want to execute code in the function beyond the catch block. 
    C. Both A and B.
A B C
08. Which might be good measures of the readability of a program?
    A. runtime efficiency   
    B. memory usage  
    C. orthogonality  
    D. comment density 
A B C D
09. Scripting languages generally beat compiled language for which? 
    A. runtime efficiency  B. memory usage   C. writeability   D. reliability
A B C D
10. Which language has dominated system programming for the last 40 years?
    A. C        B. Java       C. Fortran     D. Assembly 
A B C D
11. Which of the following is a client-side scripting language?
    A. Perl     B. Python    C. PHP     D. JavaScript
A B C D
12. Select the true statements.
    A. Java source code is compiled into bytecode and executed by the Java VM.
    B. Java bytecode can run on multiple platforms without recompilation.
    C. Some cell phones have Java support built into hardware. 
    D. Java is a procedural and an O-O language.
A B C D
13. One valid criticism of the Unix development platform is
    A. the lack of software development tools.       
    B. the lack of an IDE (integrated development environment).
    C. both A and B 
A B C
14. Which language has dominated scientific computing over the past 40 years?
    A. Fortran       B. Cobol        C. Lisp       D. C  
A B C D
15. Which language has dominated business applications over the past 40 years?
   A. Fortran       B. Cobol        C. Ada       D. C 
A B C D
16. Scheme is a dialect of which language?
    A. Fortran       B. Cobol        C. Lisp      D. SNOBOL   
A B C D
17. What programming language is used primarily for AI?
    A. Fortran       B. Cobol        C. Lisp      D. SNOBOL 
A B C D
18. The UNIX operating system is written primarily in which language?
    A. Fortran       B. Assembly      C. Lisp     D. C   
A B C D
 
19. What is the primary disadvantage to multiple ways of doing the same thing?
    A. readability     B. reliability    C. writeability  
A B C
20. Which of the following does not promote readability?
    A. orthogonality      B. type checking    C. code reusability  
A B C
21. What is true about user-defined operator overloading?
    A. If done improperly, it can harm the readability of a program.
    B. If done properly, it can improve the readability of a program.
    C. both A & B 
A B C
22. Which is an example of non-orthogonality in the design of C?
    A. The meaning of the '*' symbol depends on the context. 
    B. Arrays cannot be returned by functions.
    C. Both A & B 
A B C
23. What language uses orthogonality as a primary design criterion?
    A. Ada       B. ALGOL 68      C. Java      D. Python  
A B C D
24. What primitive control statement can build all others? 
    A. switch          B. goto       C. for      D. if-else 
A B C D
25. What is the disadvantage to using the same closing reserved word or symbol 
    for more than one kind of control statement?
    A. readability       B. writeability        C. both A and B 
A B C
26. The licensing costs of the compiler is part of the overall cost of a 
    programming language. 
T F
27. What construct of a programming language provides process abstraction?
    A. subprograms  B. if statements   C. while loops    D. structures  
A B C D
28. Software reliability means that the program
    A. never has an exception during runtime.
    B  has an intuitive user interface.
    C. behaves according to specifications under all conditions. 
A B C
29. Two or more distinct referencing names for the same memory location is 
    A. parallelism        B. aliasing 
A B
30. In a exception handling facility, what type of code would you put after a 
    throw in a try block? 
    A. The code you want executed after a non-critical exception has occurred.
    B. The code you want executed if an exception hasn't occurred.
    C. You should not put any code after a throw in a try block.
A B C
31. The strongest influence on language design over the past 45 years has been
    A. improvements in computer architecture
    B. memory cost 
    C. the need to make programs more reliable 
    D. object-oriented methodology 
A B C D
32. Which categories of languages are dictated by the von Neumann architecture?
    A. functional    B. procedural   C. imperative    D. declarative 
A B C D
33. Which two deficiencies were discovered as a result of research in software 
    development in the late 60s and early 70s and which subsequently resulted 
    in structured languages such as Pascal?

A. insufficient control statements 
B. insufficient data structures
C. insufficient type checking 
D. lack of recursion
A B C D
34. Which two language design criteria are more often in direct conflict?
    A. readability and reliability      B. readability and writability 
A B
35. Which approach to language implementation generally results in the fastest 
    program execution?
    A. compilation        B. runtime interpreter 
A B
36. What is true about the symbol table used by the compiler?
    A. It is created during compilation and used throughout program execution.
    B. It contains information needed by the compiler such as type and scope
       attribute of all symbols.
    C. both A & B
A B C
37. What does a static linker do?
    A. collects system libraries and links them to user programs 
    B. resolves external linkage between compilation units
    C. both A and B 
A B C
38. The "von Neumann bottleneck" is the limit on what?
    A. speed of execution due to memory-to-processor throughput
    B. the amount of memory that can be used for cache
    C. both A and B.  
A B C
39. Which are advantages of coding under a pure interpreter over a compiler?
    A. ease of modification    
    B. ease of runtime debugging facilities
    C. runtime efficiency
    D. source portability 
A B C D
40. A declarative language can also be imperative.  
T F

  Right: Wrong: Percent: (Must be 100% for credit)

Errors:

Name (first name only): Sleipnir Username: 3-digit ID: