CMPS 3500 - ProgLang Midterm

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

<div class="Code"> BNF GRAMMAR 1 &lt;expr> ::= &lt;expr> + &lt;term> | &lt;term> - &lt;term> &lt;term> ::= &lt;var> | const &lt;var> ::= a | b | c | d </div> 04. The rule &lt;expr> ::= &lt;expr> + &lt;term> from GRAMMAR 1 makes addition A. left associative. B. right associative.

A

05. Which constructs were in the original specification of LISP? A. atoms B. lists C. arrays D. numbers

A,B

16. Select the true statements. BASIC A. was the first widely used time-sharing language. B. was originally designed for non-science students. C. was first implemented on an Intel microprocessor. D. is a functional language.

A,B

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

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,D

12. Which statements are true regarding the COBOL language? A. COBOL was developed by computer manufacturers and the Dept. of Defense. B. A 1997 Gartner Group report found 80% of the world's business apps ran on COBOL. C. All subsequent imperative languages are based on COBOL. D. COBOL was the first language to separate code and data in memory.

A,B,D

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,D

01. Which of the following Java language components are lexemes? A. * B. identifier C. while D. integer

A,C

32. Perl was written by Larry Wall at JPL to combine or extend which languages? A. Unix shell utilities (awk, sed, sh) B. Fortran C. C D. assembly

A,C

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,C

05. Which statements are true in the language defined by GRAMMAR 1? A. subtraction will always be evaluated before addition B. a '+' terminal will be lower in the parse tree than a '-' terminal C. the evaluation order of '+' and '-' will vary depending on the context D. there are 5 terminals in the language

A,D

02. Which of the following Java constructs is a token? A. for B. literal C. both A & B

B

03. Programming languages are primarily defined by what type of grammar? A. context-sensitive B. context-free C. regular D. unrestricted

B

04. The first Fortran compiler was developed in which decade? A. 1940 B. 1950 C. 1960 D. 1970

B

04. Which criterion for a good programming language is C most deficient in? A. efficiency B. reliability C. readability D. writeability

B

06. The following is a valid expression in GRAMMAR 1. a + b - c

B

10. In an imperative language, the primary operation is A. the if statement B. the assignment statement C. the loop D. all three

B

11. The LISP language was written in what decade? A. 1940 B. 1950 C. 1960 D. 1970

B

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

B

13. What missing language element of ALGOL 60 damaged its chances for widespread use? A. dynamic memory B. input/output statements C. pass by reference

B

15. Which language has dominated business applications over the past 40 years? A. Fortran B. Cobol C. Ada D. C

B

15. Which language provided the basis of all subsequent imperative languages, although the language itself was never widely used? A. PL/I B. ALGOL C. Ada D. SIMULA

B

17. Why was BASIC an important language in the early 1980s? A. BASIC was the first structured programming language. B. Microcomputers had small memories and BASIC interpreters were very small. C. both statements are true

B

20. Which of the following does not promote readability? A. orthogonality B. type checking C. code reusability

B

22. Which design criteria were used extensively in ALGOL 68? A. reliability B. orthogonality C. concurrency D. objects

B

23. What language uses orthogonality as a primary design criterion? A. Ada B. ALGOL 68 C. Java D. Python

B

23. Which language is considered to be too large and complex? A. Ada B. PL/I C. LISP D. ALGOL

B

24. What primitive control statement can build all others? A. switch B. goto C. for D. if-else

B

27. Smalltalk, developed by Alan Kay et al. at Xerox, is a precurser for which language paradigm? A. functional B. object-oriented C. procedural D. declarative

B

29. Two or more distinct referencing names for the same memory location is A. parallelism B. aliasing

B

30. Delphi is derived from which language? A. Ada B. Pascal C. Fortran D. C

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.

B

34. Which of the following is a true statement? A. Functions may exist outside classes in both C++ and Java. B. Functions may exist outside classes in C++ but not in Java.

B

34. Which two language design criteria are more often in direct conflict? A. readability and reliability B. readability and writability

B

35. What is true regarding C#? A. C# is a compiled language like C++. B. C# is a hybrid language like Java and compiled into bytecode first.

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

B

38. What characteristic of Java is most evident in JavaScript? A. how classes are created and used B. the syntax of control statements C. dynamic typing

B

40. A declarative language can also be imperative.

B

40. JavaServlets are part of what technology? A. JavaScript B. JSP C. .NET D. XSLT

B

43. Which of the following is an imperative construct that was added to LISP? A. car B. setf C. cons D. lambda

B

44. Common LISP is a typeless language. A. True B. False

B

46. What will this LISP function return if you call it with (foo '(1 2 3))? (defun foo (x) (if (null x) 0 (+ (foo (cdr x)) (car x)))) A. return 3 B. return 6

B

48. This function will return T if the last element in the list y is equal to the value of x, otherwise NIL. (defun stuff (x y) (if (null y) nil (if (eql (car y) x) t (stuff x (cdr y))))) A. True B. False

B

49. In a LISP interpreter what will this lambda expression return? ((lambda (x) (+ x 100)) 1) A. 1 B. 101 C. nothing, x has not been assigned a value

B

09. The "psuedocode" languages prior to Fortran were designed to overcome which hardware deficiencies? A. multiple CPUs B. index registers C. floating-point support D. pipelining

B,C

32. Which categories of languages are dictated by the von Neumann architecture? A. functional B. procedural C. imperative D. declarative

B,C

01. What is true about Fortran? A. It was designed specifically for the VAX 3000. B. Designer John Backus was first and foremost a hardware designer. C. Backus claimed Fortran would virtually eliminate coding errors. D. Backus later retracted his earlier claim regarding coding errors.

B,C,D

08. What behaviors differentiate dynamic typed languages from non-dynamic ones? A. the value of a variable may change at runtime B. the address of a global variable may change at runtime C. the type of a variable may change at runtime D. the size of a global variable may change at runtime

B,C,D

08. Which of the following conditions are necessary and sufficient to claim that a context-free grammar is ambiguous? A. at least one rule contains the epsilon symbol (the empty list). B. the LHS appears twice in the RHS the rule (double-recursion). C. parsing a sentence in the grammar results in two distinct parse trees. D. a choice of two production rules can be successfully applied at one step.

B,C,D

09. Select the true statements. In the model of grammars developed by Chomsky A. the language of a^nb^nc^n; i.e., {abc,aabbcc,aaabbbccc,...}, is regular. B. context-free grammars and BNF grammars are theoretically equivalent. C. a regular grammar is Chomsky's most restrictive form of grammar. D. high-level programming languages are primarily context-free languages.

B,C,D

33. The code below will execute without an error in Javascript. Per this example what can you conclude about Javascript? (<a href="./examples/week2/test.html">see code</a>) var x = 5; var y = "hi"; var z = x + y; // Line 3 - produces "hi4.5" y = 2.5; z = y + 7; // produces 9.5 A. Javascript is a typeless language. B. Javascript is a dynamically typed language. C. Var x is coerced temporarily into a string at Line 3. D. Javascript overloads the '+' operator.

B,C,D

39. Which of the following were goals in the design of C++? A. reliability B. to support legacy C programs C. to allow an organization similar to Simula 67 D. generic programming

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.

C

03. How did index registers, which first appeared in the IBM 701 in 1955, influence the evolution of programming languages? A. by eliminating the need for absolute addressing into arrays B. by allowing loop operations on arrays to be implemented more efficiently C. both A and B

C

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.

C

09. Scripting languages generally beat compiled language for which? A. runtime efficiency B. memory usage C. writeability D. reliability

C

14. The first COBOL compiler was released in what decade? A. 1940 B. 1950 C. 1960 D. 1970

C

16. Scheme is a dialect of which language? A. Fortran B. Cobol C. Lisp D. SNOBOL

C

17. What programming language is used primarily for AI? A. Fortran B. Cobol C. Lisp D. SNOBOL

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

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

C

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.

C

28. Which language(s) were forced on programmers by the Department of Defense? A. Ada B. COBOL C. both A and B

C

36. Which of the following features are in C++ but not in Java? A. the goto statement B. pass by reference C. both A and 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

C

41. Which statement is true in LISP? A. In prefix notation, an operator can take any number of arguments. B. In LISP, everything but NIL and 0 is true. C. Both statements are true.

C

42. Why were imperative features added to LISP? A. To reduce function calls and make LISP more efficient. B. To improve writeability and readability. C. Both A and B

C

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;

C,D

02. Which feature(s) were not in Fortran 0? A. assignment statements B. subroutines C. loop control statements D. string data types

C,D

08. Which might be good measures of the readability of a program? A. runtime efficiency B. memory usage C. orthogonality D. comment density

C,D

11. Which of the following is a client-side scripting language? A. Perl B. Python C. PHP D. JavaScript

D

18. PL/I was designed to replace which language? A. Fortran B. COBOL C. ALGOL D. all three

D

18. The UNIX operating system is written primarily in which language? A. Fortran B. Assembly C. Lisp D. C

D

20. Classes and inheritance, now important parts of object-oriented languages, were initially introduced in which language? A. LISP B. SNOBOL C. Prolog D. Simula 67

D

24. Algorithms are written as a series of statements (rules and facts) that evaluate to true or false in which language paradigm? A. functional B. logic C. declarative D. both B & D

D

25. Which language was designed to facilitate string processing? A. LISP B. Algol C. Prolog D. SNOBOL

D

37. Ada was primarily designed for what application area? A. engineering B. business C. number crunching D. embedded systems

D

50. LISP functions return an atom or a list. T is an atom and () is both. A. True B. False

A

47. What does this LISP function return if you call it with (thing '(a b c))? (defun thing (x) (if (NULL x) NIL (if (listp (car x) ) T (thing (cdr x))))) A. NIL B. T

A

03. Assume you have a Student class in C++ that uses dynamic memory allocation for the student's name: <code> char *name; </code> 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

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

06. The primary reason for the relative slowness of pseudocode interpreters in the early 1950s was what? A. floating-point arithmetic done in software rather than hardware B. insufficient memory C. both A and B

A

07. Following GRAMMAR 1, the first sentential form in the derivation of the expression below is what? a - b + c A. &lt;expr> + &lt;term> B. &lt;term> - &lt;term>

A

07. The writer and designer of Fortran (John Backus) was also the co-designer of which of the following? A. the IBM computer architecture that the Fortran compiler ran on B. the LISP programminhg language C. the VAX minicomputer architecture

A

10. A statement list in Perl is one or more statements separated by semi-colons and enclosed in curly braces. Which is a correct BNF grammar for a Perl statement list? (The curly braces and semicolon are terminal symbols.) A. &lt;stmt_list> ::= { &lt;stmts> } &lt;stmts> ::= &lt;stmt> | &lt;stmt>; &lt;stmts> B. &lt;stmt_list> ::= { &lt;stmt> } | { &lt;stmt>; &lt;stmt_list> }

A

10. Which language has dominated system programming for the last 40 years? A. C B. Java C. Fortran D. Assembly

A

14. Which language has dominated scientific computing over the past 40 years? A. Fortran B. Cobol C. Lisp D. C

A

19. PL/I was designed for what type of computer? A. mainframe B. minicomputer C. microcomputer D. embedded system

A

19. What is the primary disadvantage to multiple ways of doing the same thing? A. readability B. reliability C. writeability

A

21. What innovation of data structuring was introduced in ALGOL 68 but is often credited to Pascal? A. user defined data types B. dynamic memory C. arrays

A

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

26. The licensing costs of the compiler is part of the overall cost of a programming language.

A

26. When Ada was designed what feature set it apart from other languages? A. concurrancy B. data-oriented C. procedure-oriented

A

27. What construct of a programming language provides process abstraction? A. subprograms B. if statements C. while loops D. structures

A

29. What Ada construct is similar to classes in the object-oriented paradigm? A. packages B. procedures

A

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

31. Which language was developed specifically for web programming? A. PHP B. Python C. Ruby D. Perl

A

35. Which approach to language implementation generally results in the fastest program execution? A. compilation B. runtime interpreter

A

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

45. In a static scoped language like C, what will function g return? x = 0; int f() { return x; } int g() { int x = 1; return f(); } A. 0 B. 1 C. f()

A


Set pelajaran terkait

APUSH - Period 4, 75 College Board Questions

View Set

Science 908 lifepac test study guide

View Set

CISCO CCNA I - Module 11 - IPv4 Addressing (Test Notes)

View Set

Elements, Compounds, and Mixtures

View Set

Anatomy and Physiology 2 Lymphatics and Immunity

View Set

Religion Textbook Assignment pg. 118

View Set