Test 1 (24S1) Chapters 1-3, 5-6 PDF

Summary

This is a programming quiz for a computer science course. The quiz covers the topics of programming languages, compilers, and context-free grammars, and includes multiple-choice questions. The questions span different aspects of programming languages, and the quiz was taken on Tuesday, 24 September 2024.

Full Transcript

1 Home Dashboard My courses   ...

1 Home Dashboard My courses      Quiz Navigation CMPS3111  Test 1 (24S1): Chapters 1-3, 5-6 MULTIPLE QUIZ CHOICES Test 1 (24S1): Chapters 1-3, 5-6 QUESTIONS (30 Started on Tuesday, 24 September 2024, 8:00 AM points) State Finished 1 2 3 4 5 6 Completed on Tuesday, 24 September 2024, 8:47 AM Time taken 47 mins 1 sec 7 8 9 10 11 12 Marks 43.39/54.00 Grade 80.35 out of 100.00 13 14 15 16 17 18 Question 1 What role does the symbol table play in a compiler? (choose one) 19 20 21 22 23 24 Correct Mark 1.00 out of Select one: 25 26 27 28 29 30 1.00 a. Stores the reserved words Flag question b. Records the number of syntax errors c. Serves as the database of information about the program BNF GRAMMAR d. Allows high-quality error messages DERIVATION (10 points) 31 The correct answer is: Serves as the database of information about the program  Question 2 Context-free grammars were devised by: (choose one) Correct Mark 1.00 out of Select one: 1.00 a. Peter Naur Flag question b. John Backus c. John McCarthy d. Noam Chomsky The correct answer is: Noam Chomsky Question 3 A language is strongly typed if: (choose one) Correct Mark 1.00 out of Select one: 1.00 a. Type checking is done at compile-time Flag question b. Type checking is done at run-time c. Type errors are always detected d. Its operands and operators are of compatible types The correct answer is: Type errors are always detected Question 4 Which one of the following is not a primitive data type? Correct Mark 1.00 out of Select one: 1.00 a. Floating point Flag question b. Integer c. A single-dimensional array of integers d. Boolean The correct answer is: A single-dimensional array of integers Question 5 A grammar is ambiguous if it: (choose one) Correct Mark 1.00 out of Select one: 1.00 a. Produces a sentential form that has two distinct parse trees Flag question b. Has a rule with more than four RHSs c. Has rules with the same LHS and RHS d. Has two rules that have the same RHSs The correct answer is: Produces a sentential form that has two distinct parse trees Question 6 Which one of the following is not a primary design issue for pointers? Correct Mark 1.00 out of Select one: 1.00 a. Should the language support pointer types, reference types, or both? Flag question b. Can pointers point to other pointers? c. What is the lifetime of a heap-dynamic variable? d. Are pointers restricted as to the type of value to which they can point? The correct answer is: Can pointers point to other pointers? Question 7 Which one of the following is not an advantage in implementing a language with a pure interpreter? Correct Mark 1.00 out of Select one: 1.00 a. Code execution time is very fast Flag question b. The implementation is relatively simple c. Source-level debugging operations are easily implemented d. Storing the whole source program requires significant storage for large programs The correct answer is: Code execution time is very fast Question 8 Which one is not an attribute type of Attribute Grammars? Correct Mark 1.00 out of Select one: 1.00 a. Inherited Flag question b. Synthesized c. Intrinsic d. Predicate The correct answer is: Predicate Question 9 What is the key difference between static and dynamic scoping? (choose one) Correct Mark 1.00 out of Select one: 1.00 a. Dynamic scoping is more flexible and efficient Flag question b. Are based on temporal and spatial relationships of subprograms respectively c. Static scoping is more reliable but at the expense of readability d. The scope of a variable can be determined prior to execution and only at run-time respectively The correct answer is: The scope of a variable can be determined prior to execution and only at run-time respectively Question 10 What construct of a programming language provides process abstraction? (choose one) Correct Mark 1.00 out of Select one: 1.00 a. pointers Flag question b. classes c. subprograms d. arrays The correct answer is: subprograms Question 11 Which one of the following is not a good reason to study programming languages? Correct Mark 1.00 out of Select one: 1.00 a. Increased ability to discuss programming languages Flag question b. Better understanding of the significance of implementation c. Increased ability to learn new languages d. Increased capacity to express ideas The correct answer is: Increased capacity to express ideas Question 12 Which one of the following is not a category of scalar variables defined by their lifetimes? Correct Mark 1.00 out of Select one: 1.00 a. stack Flag question b. implicit heap-dynamic c. explicit heap-dynamic d. implicit stack-dynamic The correct answer is: implicit stack-dynamic Question 13 Which one of the following languages uses the fewest number of coercions in arithmetic expressions? Correct Mark 1.00 out of Select one: 1.00 a. Ada Flag question b. C c. C++ d. Java The correct answer is: Ada Question 14 What do the Ada and COBOL languages have in common? (choose one) Correct Mark 1.00 out of Select one: 1.00 a. Both are for business applications Flag question b. Both were forced on users by DoD c. Both took a long time to develop d. Both are for scientific applications The correct answer is: Both were forced on users by DoD Question 15 On what language was COBOL based? (choose one) Correct Mark 1.00 out of Select one: 1.00 a. FLOW-MATIC Flag question b. FORTRAN c. LISP d. ALGOL 58 The correct answer is: FLOW-MATIC Question 16 Which one of the following dynamic semantic methods systems is most mathematical? Correct Mark 1.00 out of Select one: 1.00 a. Static semantics Flag question b. Axiomatic semantics c. Denotational semantics d. Operational semantics The correct answer is: Denotational semantics Question 17 Which one of the following languages does not have pattern matching built in to the language? Complete Not graded Select one: Flag question a. JavaScript b. Perl c. Java d. PHP The correct answer is: Java Question 18 What is exception handling? (choose one) Correct Mark 1.00 out of Select one: 1.00 a. Dealing with different ranges of parameter values in a subprogram Flag question b. Allowing a program to intercept run-time errors, take corrective measures, and then continue execution c. Dealing with the syntactic irregularities of a programming language d. Dealing with syntax errors during compilation The correct answer is: Allowing a program to intercept run-time errors, take corrective measures, and then continue execution Question 19 Which one is not a variable attribute? (choose one) Correct Mark 1.00 out of Select one: 1.00 a. alias Flag question b. lifetime c. address d. scope The correct answer is: alias Question 20 What user group was the target of the first version of BASIC? (choose one) Correct Mark 1.00 out of Select one: 1.00 a. Liberal arts students Flag question b. Accountants c. Engineering students d. Scientists The correct answer is: Liberal arts students Question 21 Which one of the following is a terminal symbol in the grammar rule: Correct < expr > → (+ | -) ident | ident | (< expr >) Mark 1.00 out of 1.00 Select one: Flag question a. -- b. ident c. < expr > d. ++ The correct answer is: ident Question 22 What characteristic of Java is most evident in JavaScript? (choose one) Complete Not graded Select one: Flag question a. Syntax b. Strong typing c. Object orientation d. Semantics The correct answer is: Syntax Question 23 Which one of these languages have case-sensitive names? Correct Mark 1.00 out of Select one: 1.00 a. Fortran Flag question b. C c. Ada d. COBOL The correct answer is: C Question 24 BNF abstractions are represented by: (choose one) Correct Mark 1.00 out of Select one: 1.00 a. Terminal symbols Flag question b. Rules c. Sentences d. Non-terminal symbols The correct answer is: Non-terminal symbols Question 25 What is the name of the category of programming languages whose structure is dictated by the von Neumann computer Correct architecture? (choose one) Mark 1.00 out of 1.00 Select one: Flag question a. Functional b. Systems c. Scientific d. Imperative The correct answer is: Imperative Question 26 Which one is an eager approach to garbage collection? Incorrect Mark 0.00 out of Select one: 1.00 a. lock-and-key Flag question b. tombstones c. reference counters d. mark-sweep  The correct answer is: reference counters Question 27 Which one of the following languages does not allow dynamic binding of values to named constants? Incorrect Mark 0.00 out of Select one: 1.00 a. C++ Flag question b. Fortran 95 c. Ada d. Java  The correct answer is: Fortran 95 Question 28 Which is not a possible binding time? (choose one) Correct Mark 1.00 out of Select one: 1.00 a. load Flag question b. design c. termination d. implementation The correct answer is: termination Question 29 What design criterion was used extensively in ALGOL 68? (choose one) Correct Mark 1.00 out of Select one: 1.00 a. Orthogonality Flag question b. Reliability c. Readability d. Simplicity The correct answer is: Orthogonality Question 30 What was the primary application area of computers at the time Fortran was designed? Correct Mark 1.00 out of Select one: 1.00 a. Scientific Flag question b. Computer gaming software c. Business d. Artificial intelligence The correct answer is: Scientific Question 31 Using the BNF grammar below: Correct → = Mark 6.00 out of p|q|r|s|t 6.00 → + Flag question - → | | Given the string: p=q-t +r Complete the RIGHTMOST derivation below. NOTE: Each blank contains ONLY ONE terminal or non-terminal symbol. → =    → = +      → = + r      → = - + r        → = - + r        → = - t + r        → = q - t + r        → p = q - t + r        Question 32 Match items on the left with the most appropriate item on the right. Incorrect Mark 0.00 out of Allowing visibility of non-local variables in subprograms 4.00 Referencing environment  Flag question Collection of all of the variables that are visible to a statement Static scoping  Binding occurs before run time and can change during execution Static binding  Two or more names bound to the same storage address Dynamic binding  Variable referenced only through pointers Referencing environment  The correct answer is: Allowing visibility of non-local variables in subprograms → Static scoping, Collection of all of the variables that are visible to a statement → Referencing environment, Binding occurs before run time and can change during execution → Dynamic binding, Two or more names bound to the same storage address → Aliases, Variable referenced only through pointers → Explicit heap-dynamic Question 33 Match the item on the left with the most appropriate concept on the right. Partially correct Mark 2.40 out of Functional 4.00 Programming Language Criteria  Flag question Readability Programming Language Criteria  Cost Programming Language Methodology  Object-oriented Programming Language Category  Scientific Programming Language Domain  The correct answer is: Functional → Programming Language Category, Readability → Programming Language Criteria, Cost → Programming Language Criteria, Object-oriented → Programming Language Category, Scientific → Programming Language Domain Question 34 Complete the following: Partially correct 1. Only the compile-time  is required for arrays with static attributes with no run-time checking. Mark 3.79 out of 4.00 2. Checking of index ranges during execution may require a run-time  descriptor. Flag question 3. Subscript expressions are mapped to an address in an array with the access function . 4. The access function is constructed from information included in the array  descriptor. Given the 4 x 4 array below, answer questions 5 and 6. 9 6 7 4 2 1 0 8 7 5 9 2 8 3 1 6 Complete the following using the two common ways that multi-dimension arrays are mapped onto linear hardware memory: 5. The linear mapping using column major  order used in Fortran is: 9  , 2  , 7  , 8  , 6  , 1  , 5  , 3  , 7  , 0  , 9  , 1  , 4  , 8  , 2  , 6  6. The linear mapping using row major  order used in most languages is: 9  , 6  , 7  , 4  , 2  , 1  , 0  , 8  , 7  , 5  , 9  , 2  , 8  , 3  , 1  , 6  Question 35 Consider the FORTRAN array GRID ( 10 ,10 ) and the corresponding references syntax where: Partially correct GRID ( : , 5 ) refers to the fifth column of Grid Mark 1.20 out of GRID ( 5 , : ) refers to the fifth row of Grid 4.00 GRID ( : , 3:4 ) refers to the third and fourth column of Grid Flag question Using the FORTRAN syntax above, what are the references for the slices (shaded) of the arrays shown diagrammatically below: MAT ( 1:4  , 2:3  ) CUBE ( 3  , 1:3  , 1:2  ) CARD( 3  , 1:3  ) BLOCK( 1:3  , 1:4  , 1:3  ) Question 36 Complete the following statements: Correct 1. One of the first higher-level languages, Shortcode was proposed by John Mauchly . Mark 4.00 out of 4.00 2. Designed to support computation with floating-point numbers, Speedcoding was developed by John Backus . Flag question 3. The LISP language was designed by John McCarthy . 4. Ada Byron  is regarded as the world's first computer programmer. 5. An object-oriented language, Eiffel was designed by Bertrand Meyer . Finish review Quick Links Follow Us Contact About UB Hummingbird Avenue, City of  Facebook The Information Technology Belmopan Program prepares students for About FST work, further study and research  Twitter  Phone: (501) 822-1000/ 822-3680 Faculty and Staff in the Information Technology field locally, regionally and globally. UB Virtual Tour The program provides knowledge, UB Student Portal skills and the discipline that will enable graduates to make a UB ACM Student Chapter positive impact on the working environment and be able to function as entrepreneurs in the community. Copyright © 2020 - Developed by UB MPIT-IT. Powered by Moodle

Use Quizgecko on...
Browser
Browser