《C++面向对象程序设计考试题库.docx》由会员分享,可在线阅读,更多相关《C++面向对象程序设计考试题库.docx(136页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、SHORTANSWER1. Aset of instructions that the computer will follow is called a. Answer: program2. The collection of programs used by the computer is known as. Answer: software3. Computers that are interconnected are known as a. Answer: network4. A digit that can hold a zero or a one is known as a. Ans
2、wer: bit5. List at least two input devices. Answer: keyboard, mouse, network card, file6. List at least two output devices. Answer: screen, printer, file, network card7. A variable that can hold a whole number is called a(n). Answer: integer8. What punctuation signifies the end of a C+ statement? An
3、swer: A semicolon.9. A mistake in a computer program is called a. Answer: bug10. A is the program that translates a program written in C+ into machine language.Answer: compiler11. Errors in a program can be classified into three types, list them Answer: Syntax, logic,run-time12. What does the follow
4、ing statement in C+ print to the screen? cout ”Hello students);Answer: Hello students.13. A mistake that is a direct violation of the syntax rules will generate a compiler. Answer: error14. If your program compiles and runs, but gives an incorrect output, this is known as a error.Answer: logic15. Th
5、e part of the computer that controls and executes programs is called the. Answer: CPUMULTIPLE CHOICE1. Who was the programmer for Charles Babbages analytical engine?a. Grace Hopper b. Ada Lovelace c. Lord Bryan d. Waller SavitchAnswer: B2. An algorithm isa. The inputs and outputs of a programb. The
6、part of the computer that does the processingc. A finite set of steps to solve a problemd. A complete computer programAnswer: C3. A memory address isa. Where a variable is storedb. Where the computer is locatedc. A step in the program.d. Where the CPU is stored.Answer: A4. A computer that is normall
7、y used by only one person at a time is called aa. Serverb. Mainframec. Personal Computerd. NetworkAnswer: C5. The physical machines that make up a computer is called thea. Softwareb. Networkc. Devicesd. CPUe. HardwareAnswer: E6. Which of the following is not a phase of the program-design process?a.
8、Problem-solvingb. Implementationc. Marketing the final programAnswer: C7. Which of the following is not part of the Software Life Cycle?a. Analysisb. Designc. Data Entryd. Implementatione. TestingAnswer: C8. From which language did C+ directly evolve?a. Ab. Adac. Cd. C+e. C-Answer: C9. What does the
9、 following line of code display to the screen?cout ”This is the computern programming bookn”;a. This is the computem programming bookb. This is the computerc. Nothingd. This is the computer programming bookAnswer: D10. C+ statements end with aa. Periodb. Commac. SemicolonAnswer: Cd. Nothing11.12.Whi
10、ch of the following is not an example of a program bug?a. Run-time errorb. Operator errorc. Syntax errord. Logic errorAnswer:BWhat does the following code print to the screen?cout vv hello”;a. Hellob. helloc. HELLOd. NothingAnswer: B13.14.15.16.17.The set of instructions that a computer will follow
11、ia. Hardwareb. Algorithmc. Programd. CPUThe anagram CPU stands fora. Computer Programming Unitb. Central Processing Unitc. Central Program Userd. Computer Paper UserThe output of the compiler is calleda. The programb. Source codec. Linked coded. Object codeThe term OS stands fora. Operating Systemb.
12、 Oscillating Systemc. Operations Servicesd. NothingWho designed the first programmable computer?a. IBMb. Microsoftc. Inteld. Babbagee. Dells known as:Answer: CAnswer: B Answer:DAnswer: AAnswer: D18. A finite sequence of precise instructions that leads to a problem solution is a. A program b. The CPU
13、c. A List of Inputs and Outputsd. An AlgorithmAnswer: D19. Who developed C+?a. Bjame Stroustrupb. Ken Thompsonc. Charles Babbaged. Ada LovelaceAnswer: A20. One of the biggest difference between C and C+ is:a. C is object-orientedb. C+ is object-orientedc. All C+ programs are also C programsd. C only
14、 runs on UNIX computersAnswer: B21. int number;a. is an output statementb. is an input statementc. is a variable declarationd. is a programAnswer: C22. cout How many items would you want?n;a. is an output statementb. is an input statementc. is a variable declarationd. is a programAnswer:A23. cin num
15、ber;Ais an output statementBis an input statementCis a variable declarationDis a programAnswer:B23. What does the following print to the screen? cout Hello Students/n”;a. Hello Studentsb. hello Studentsc. HELLO STUDENTSd. Hello Students/nAnswer:D24. #include a. is a variable declarationb. an executa
16、ble statementc. an include directived. illegal codeAnswer: C25. A byte consists of how many bits?a. 6b. 7c. 8d. 9e. 10Answer: C26. What is wrong with the following statement?cout Hello to everyonena. cout should be countb. missing a semicolonc. missing a ”批注WS1J: 28 and 27 are the same批注 fMH21: 27 a
17、nd 28 are different, 27 is missing a semicolon, while 28 is missing the closing double quote.d. missing a (Answer: B27. What is wrong with the following (statement?cout Hello to everyonen;a. cout should be countb. missing a semicolonc. missing a ”d. missing a (Answer: C28. C+ is an example of aa. Ma
18、chine languageb. High-level languagec. Low-level languaged. Assembly languageAnswer: B29. RAM stands fora. Read access memoryb. Random access memoryc. Really atrocious memoryd. A hard driveAnswer: BTRUE/FALSE1. Grace Hopper discovered the first documented computer bug.Answer: TRUE2. The following st
19、atement is legal:cout Hello, my name is Billn”;Answer: FALSE3. Ybu should write your program before you write the algorithm.Answer: FALSE4. It is considered better style to put the braces () on separate lines. Answer: TRUE5. The compiler will catch all your programming mistakes.Answer: FALSE6. C+ is
20、 a low-level language.Answer: FALSE7. Main memory holds its data if the computer is turned offAnswer: FALSE8. An algorithm is always written in C+Answer: FALSE9. There are 8 bytes in one bit.Answer: FALSE10. The printer is an example of an input device.Answer: FALSETRUE/FALSE1. In the following code
21、 fragment, x has the value of 3.int x = 3;ANSWER: TRUE2. The body of a do-while loop always executes at least once.ANSWER: TRUE3. The body of a while loop may never execute.ANSWER: TRUE4. The opposite of (x 3 & x 10) is (x 10)ANSWER: FALSE5. The integer 0 is considered true.ANSWER: FALSE6. Loops are
22、 used when we need our program to make a choice between two or more things. ANSWER: FALSE7. It is legal to declare more than one variable in a single statement.ANSWER: TRUE8. Variable names may begin with a number.ANSWER: FALSE9. The opposite of less than is greater thanANSWER: FALSE10. Every line i
23、n a program should have a comment.ANSWER: FALSEShort Answer1. is called the operator.ANSWER: insertion2. The braces for a loop define the of the loop.ANSWER: body3. A loop that always executes the loop body at least once is known as a loop.ANSWER: do-while4. int my Value; is called a.ANSWER: variabl
24、e declaration5. What is the opposite of ( x 12)?ANSWER: (x =20II x 19&x 99)7. Each time a loop body executes is known as an. ANSWER: iteration8. if-else statements that are inside other if-else statements are said to be. ANSWER: nested9. is known as the operator.ANSWER: extraction10. Is used for inp
25、ut or output?ANSWER: outputIL The stream that is used for input from the keyboard is called. ANSWER: cin12. The stream that is used for output to the screen is called. ANSWER: cout13. Write the loop condition to continue a while loop as long as x is negative.ANSWER: while(x myFloat;b. cin my Float;c
26、. cin myFloat;d. cin myFloat endl;ANSWER: A10. Another way to write the value 3452211903 isa. 3.452211903e09b. 3.452211903e-09c. 3.452211903x09d.3452211903e09ANSWER: A11.Which of the following statements is NOT legal?a.char ch二b;b.char ch=*0;c.charch=65;d.char ch=ccM;ANSWER: D12.What isthe value of
27、x after the following statements?float x;x= 15/4;a.3.75b.4.0c.3.0d.60ANSWER: C13.What isthe value of x after the following statements? int x;x= 15/4;a.15b.3c.4d.3.75ANSWER: B14.What isthe value of x after the following statements?int x;x = 15 %4;a.15b.4c.3d.3.75ANSWER: C15.What is the value of x aft
28、er the following statement?float x;x = 3.0/4.0+ 3 +2/5a.5.75b.5.75c.1.75d.3.75ANSWER: D16.What isthe value of x after the following statement? float x;x = 3.0/4.0+ (3 +2)/5a. 5.75b. 5.75c. 1.75d. 3.75ANSWER: C17. What is the value of x after the following statements?double x;x = 0;x += 3.0 * 4.0;x -
29、= 2.0;a. 22.0b. 12.0c. 10.0d. 14.0ANSWER: C18. Given the following code fragment and the input value of 4.0, what output is generated? float tax;float total;cout enter the cost of the itemn;cin total;if (total =3.0)(tax = 0.10;couttotal + (total * tax) endl;)else(couttotal endl;)a. 3b. 3.3c. 4.0d. 4
30、.4ANSWER: D19. Given the following code fragment and the input value of 2.0, what output is generated? float tax;float total;cout enter the cost of the itemn;cin total;if (total =3.0)tax = 0.10;couttotal + (total * tax) endl;elsecouttotal endl;a. 2.2b. 2.0c. 3.1d. 4.4ANSWER: B20. If x has the value
31、of 3, y has the value of -2, and w is 10, is the following condition true or false?if( x 2 & w y) a. trueb. FalseANSWER: B21. What is the correct way to write the condition y x z?a. (y x z)b. (y x) II (y z)d. (y x) & (x z)ANSWER: D22. Given the following code fragment, and an input value of 3, what
32、is the output that is generated?int x;cout rEnter a valuen;cin x;if(x=0)!cout x is zeron”;Ielsecout x is not zeron;)a. x is zerob. x is not zeroc. unable to determine23.d. x is 3ANSWER: A (note it is an assignmentGiven the following code fragment, and an input value of 5, what is the output?int x;if
33、( x 3)(coutsmallXn;if( x4)cout”mediumn;批注(WS51: But the answer is the same as if you used = instead of =. Maybe an input of 0?批注MH6J: I had witten the wrong answer! It will always print out *x is zeroelseif( x 5)cout ”x is bigger than 5.cout That is all.cout vv Goodbyen;a. x is bigger than 5. That i
34、s allb. x is bigger than 5c. That is all. Goodbyed. GoodbyeANSWER: C25. Executing one or more statements one or more times is known as:a. selectionb. iterationc. sequenced. AlgorithmANSWER: B26. Given the following code fragment, what is the final value of y?int x, y;x = -1;y = 0;while(x = 3)1y+= 2;
35、x += 1;Ia. 2b. 10d. 8ANSWER:同27. Given the following code fragment, what is the final value of y?int x, y;x = -1;y = 0;while(x 3)V 批注 FWS7: ks an infinite loop批注 LMH8J: Fixed.y+= 2;x += 1;a. 2b. 10c. 6d. 8ANSWER:回 批注WS9: another infinite loop,28. What is the output of the following code fragment?unl
36、ess I missed somethingmx=;批注while( x 0);a. 8b. 9c. 10d. 11e. infinite loopANSWER:同 通注WSU: “infinite loop” might30. Given the following code fragment, which of the following expressions is always true?be clearer than unknown*int x;皿亠批注 IMH12: Fixed cin x;a. if( x l )d. if(x= 1)ANSWER: DTRUE/FALSE1. A
37、 boolean expression may evaluate to more than 2 values ANSWER: FALSE2. A function may return a boolean value.ANSWER: TRUE3. In an enumerated data type, different constants may not have the same value. ANSWER: FALSE4. The compiler always pairs an else withANSWER: the nearest previous if not already paired with an else.5. All switch statements can be converted into nested if-else statementsANSWER: TRUE6. All nested if-else statements can be converted into switch statements.ANSWER: FALSE7. A break statement in a switch stops your program.ANSWER: FAL
限制150内