大学英语期末复习TestBank1006.pdf

上传人:33****8 文档编号:33298302 上传时间:2022-08-10 格式:PDF 页数:10 大小:69.84KB
返回 下载 相关 举报
大学英语期末复习TestBank1006.pdf_第1页
第1页 / 共10页
大学英语期末复习TestBank1006.pdf_第2页
第2页 / 共10页
点击查看更多>>
资源描述

《大学英语期末复习TestBank1006.pdf》由会员分享,可在线阅读,更多相关《大学英语期末复习TestBank1006.pdf(10页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、Test BankChapter Six (Programming Languages)Multiple Choice Questions1. Which of the following is an example of a language that is based on the functional paradigm? A. LISP B. PROLOG C. C D. C+ ANSWER: A 2. Which of the following is an example of a language that is based on the object-oriented parad

2、igm? A. LISP B. PROLOG C. C D. C+ ANSWER: D 3. Most machine languages are based on the A. Imperative paradigm B. Declarative paradigm C. Functional paradigm D. Object-oriented paradigm ANSWER: A 4. Which of the following is not a type of statement found in a typical high-level imperative programming

3、 language? A. Imperative statement B. Exclamatory statement C. Declarative statement D. Comment statement ANSWER: B 5. Which of the following does not require a Boolean structure? A. If-then-else statement B. While loop statement C. Assignment statement D. For loop statement ANSWER: C 6. Which of th

4、e following is not a control statement? A. If-then-else statement B. While loop statement C. Assignment statement D. For loop statement ANSWER: C 7. Which of the following is not a control statement? A. If-then-else statement B. While loop statement C. Assignment statement D. For loop statement ANSW

5、ER: C 8. Which of the following is not a step in the process of translating a program? A. Executing the program B. Parsing the program C. Lexical analysis D. Code generation ANSWER: A 9. Which of the following is not associated with object-oriented programming? A. Inheritance B. Resolution C. Encaps

6、ulation D. Polymorphism ANSWER: B 10. Which of the following is not associated with the concept of data type? A. Coercion B. Boolean C. Operator precedence D. Strongly typed language ANSWER: C 11. Positions within arrays are identified by means of numbers called A. Indices B. Parameters C. Instance

7、variables D. Constants ANSWER: A 12. Which of the following is ignored by a compiler? A. Control statements B. Declarations of constants C. Procedure headers D. Comment statements ANSWER: D 13. Which of the following is not a possible value of the expression 4 + 6 2 - 1 A. 4 B. 5 C. 6 D. 10 ANSWER:

8、B 14. Which of the following is not a way of referring to a value in a program? A. Variable B. Literal C. Constant D. Type ANSWER: D 15. Which of the following is the scope of a variable? A. The number of characters in the variable s nameB. The portion of the program in which the variable can be acc

9、essed C. The type associated with the variable D. The structure associated with the variable ANSWER: B 16. Which of the following is a means of nullifying conflicts among data types? A. Inheritance B. Parsing C. Coercion D. Code optimization ANSWER: C 17. Which of the following is not constructed by

10、 a typical compiler? A. Source code B. Symbol table C. Parse tree D. Object program ANSWER: A 18. Which of the following is a means of defining similar yet different classes in an object-oriented program? A. Inheritance B. Parsing C. Coercion D. Code optimization ANSWER: A 19. Which of the following

11、 is not a parse tree of an expression based on the following grammar? A. B. C. ANSWER: C 20. Which of the following statements is not a resolvent of the following clauses? P OR Q OR R P OR T Q OR T R OR T A. Q OR R OR T B. T OR P C. P OR R OR T D. Q OR T ANSWER: B 21. Which of the following can Prol

12、og conclude from the following program? parent(jill, sue). parent(jill, sally). parent(john, sue). parent(john, sally). sibling(X, Y) :- parent(Z, X), parent(Z, Y).A. parent(jill, john)B. sister(sue, sally)C. sibling(sue, sally)D. sibling(jill, sue) ANSWER: C Fill-in-the-blank/Short-answer Questions

13、1. In contrast to _ languages such as English and Spanish, programming languages are considered _ languages and are rigorously defined by their grammars. ANSWER: natural, formal 2. List two disadvantages of both machine languages and assembly languages that are overcome by high-level programming lan

14、guages. _ _ ANSWER: They are machine dependent and they require that algorithms be expressed in small machine-related steps rather that larger application-oriented steps. 3. Indicate how each of the following types of programming languages is classified in terms of generation (first generation, seco

15、nd generation, or third generation). A. High-level languages _ B. Machine languages _ C. Assembly languages _ ANSWER: A. Third generation B. First generation C. Second generation 4. List four data types that occur as primitive types in many high-level programming languages. _ _ _ _ ANSWER: Possible

16、answers include: integer, real (or float), Boolean, and character. 5. What encoding system is commonly used to encode data of each of the following types? A. Integer _ B. Real _ C. Character _ ANSWER: (CAUTION: This question relies on material from chapter 1) A. Two s complementB. Floating-point C.

17、ASCII or Unicode 6. A _ array is an array in which all entries are of the same type whereas entries in a _ array may be of different types. ANSWER: homogeneous, heterogeneous 7. In programming languages that use + to mean concatenation of character strings, the expression “2x” + “3x”will produce wha

18、t result? _ ANSWER: “ 2x3x ”8. Rewrite the following instructions using a single if-then-else statement. if (X = 5) goto 50 goto 60 50 print the value of Z goto 100 60 print the value of Y 100 . . . ANSWER: if (X = 5) then (print the value of Z) else (print the value of Y)9. The following is a progr

19、am segment and the definition of a procedure named sub. . . X 3; procedure sub (Y) sub (X); Y 5; print the value of X; . . A. What value will be printed by the program segment if parameters are passed by value? _ B. What value will be printed by the program segment if parameters are passed by refere

20、nce? _ ANSWER: A. 3 B. 5 10. The following is a program segment and the definition of a procedure named sub. . procedure sub . . X 8; . apply procedure sub; X 2; print the value of X; . . . . A. What value will be printed by the program segment if X is a global variable? _ B. What value will be prin

21、ted by the program segment if X is a declared as a local variable within the procedure? _ ANSWER: A. 8 B. 2 11. To say that a grammar is ambiguous means that _ _ . ANSWER: the grammar allows more than one parse tree for a single string 12. List three items of information that would be contained in a

22、 typical parser s symbol table._ _ _ ANSWER: Possible answers include: names of variables, data types associated with variables, data structures associated with variables, and others. 13. Give three examples of key words that are often found in high-level imperative or object-oriented languages. _ _

23、 _ ANSWER: Possible answers are numerous and include: if, while, for, class, int, etc. 14. In addition to the procedure s name, what other information is contained in a typical procedure header? _ ANSWER: A list of the formal parameters 15. In the context of the object-oriented paradigm, _ are templ

24、ates from which _ are constructed. We say that the latter is an instance of the former. ANSWER: classes, objects 16. In the context of the object-oriented paradigm, a _ is an imperative program unit that describes how an object should react to a particular stimulus. ANSWER: method (or member functio

25、n for C+ programmers) 17. Based on the sketch of a class definition below, which methods can be invoked from outside an instance of the class? class Example public void method1( ) . . . private void method2( ) . . . public void method3( ) private void method4( ) . . . _ANSWER: method1 and method3 18

26、. What clause would produce the resolvent P OR R OR S when resolved with the clause P OR Q _ ANSWER: Q OR R OR S 19. What general rule should be added to the Prolog program below so that Prolog can conclude that ice cream is better than spinach? better(icecream, peanutbutter). better(peanutbutter, s

27、pinach)._ ANSWER: The equivalent of: better(X, Z) :- better(X, Y), better(Y, Z). 20. Based on the Prolog program below, what goal should be used to find the siblings of sue? parent(jill, sue). parent(jill, sally). parent(john, sue). parent(john, sally). sibling(X, Y) :- parent(Z, X), parent(Z, Y)._

28、ANSWER: Either sibling(X, sue) or sibling(sue, X)Vocabulary (Matching) QuestionsThe following is a list of terms from the chapter along with descriptive phrases that can be used to produce questions (depending on the topics covered in your course) in which the students are ask to match phrases and t

29、erms. An example would be a question of the form, “ In the blank next to each phrase, write the term from the following list that is best described by the phrase.”Term Descriptive Phraseassembly language A step up from machine language programming paradigm A program development methodology structure

30、d programming A methodology that applies well-designed control structures to produce well-organized software grammar The rules defining the syntax of a programming language parse tree A “ pictorial” representation of the grammatical structure of a stringcompiler A program that translates other progr

31、ams into machine language interpreter A program that executes other programs written in a high-level language without first translating them into machine language high-level language A notational system for representing algorithms in human compatible terms rather than in the details of machinery sem

32、antics Meaning as opposed to appearance syntax Appearance as opposed to meaning operator precedence Dictates the order in which operations are performed data structure A conceptual organization of information parameter A means of passing information to a procedure or function data type Encompasses b

33、oth an encoding system and a collection of operations syntax diagrams A way of representing a grammar source program A program expressed in a high-level language General Format Questions1. What does it mean to say that a programming language is machine independent? ANSWER: It means that programs wri

34、tten in the language do not refer to properties of a specific machine and are therefore compatible with any computer. 2. Explain the distinction between the imperative and declarative programming paradigms. ANSWER: The imperative paradigm requires that a programmer describe an algorithm for solving

35、the problem at hand. The declarative paradigm requires that the programmer describe the problem. 3. Explain why the generation approach to classifying programming languages fails to capture the full scope of today s languages.ANSWER: The generation approach fails to reflect the array of distinct pro

36、gramming paradigms. 4. Explain the distinction between translating a program (in a high-level language) and interpreting the program. ANSWER: To translate a program is to convert it to another (usually low-level) language without executing it. To interpret a program is to execute it directly from it

37、s high-level language form. 5. Why is the straightforward “ goto ” statement no longer popular in high-level programming languages? ANSWER: Its use led to poorly structured programs that were hard to understand. 6. Explain the distinction between a formal parameter and an actual parameter. ANSWER: A

38、 formal parameter is a term used in a subprogram unit to refer to data that will be given to the subprogram when it is executed. An actual parameter is the data that is given to the subprogram unit when it is executed. (A formal parameter is a “ place holder” that is “ filled in” with an actual para

39、meter when the subprogram unit is executed.) 7. Explain the distinction between global and local variables. ANSWER: A global variable is readily accessible throughout the program whereas a local variable is accessible only within a specific area. 8. Explain the distinction between a procedure and a

40、function. ANSWER: A procedure returns values via parameters and global variables whereas a function returns a value as “ the value of the function.”9. Based on the grammar below, draw a parse tree showing that the string “ drip drip drip” is a Leak.ANSWER: 10. Show that the grammar below is ambiguou

41、s by drawing two distinct parse trees for the string “ drip drip drip.”ANSWER: Possible answers include: 11. In the context of the object-oriented paradigm, what is a constructor? ANSWER: A constructor is a special “ method ” that is executed when an object is first constructed, normally for the pur

42、pose of performing initialization activities. 12. Briefly describe the task of each of the following. A. Lexical analyzer B. Parser C. Code Generator ANSWER: A. Groups symbols together to form tokens B. Ascertains the grammatical role of program s componentsC. Constructs object program 13. Explain why key words in a programming language are often reserved words. ANSWER: Key words are used to help the parser identify grammatical structures in a program. Thus, using these words are used for other purposes could confuse the parser.

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 应用文书 > 工作报告

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁