fbla computer science c++ test · web viewwhich of the following converts program source code into...

12
2004 C++ Programming Page 1 Mark the correct answer on your Scantron sheet for each of the following questions. 1. Who invented a calculating machine that runs on electricity and whose company eventually became known as IBM? a. Aiken b. Eckert c. Hollerith d. Babbage 2. The first electronic computer which was completed in 1946 was called the a. Mark I. b. ENIAC. c. Difference Engine. d. UNIVAC. 3. What invention replaced vacuum tubes, allowing computers to become smaller and faster? a. Transistors b. Punch cards c. CPU d. Magnetic tapes 4. Blocks of silicon with logic circuits etched into their surfaces are called a. punch cards. b. transistors. c. microfibers. d. chips. 5. Which of the following converts program source code into machine language? a. An assembler b. A linker c. A compiler d. An interpreter 6. Object code is a. a machine language code produced by the compiling process. b. the actual program written in English. c. the actual program written in C++. d. the result of the linking process. 7. C++ is a hybrid language which a. combines C with plus plus. b. supports C and BASIC. c. supports object-oriented and procedural programming. d. combines Windows and Macintosh. 8. Which of the following is referred to as “main memory”? a. ROM b. RAM c. CPU d. Auxiliary 9. The binary number 11 is equivalent to what decimal number? a. 2 b. 3 c. 4 d. 111 10. What name is given to the named location in a computer’s memory, which can change during program execution? a. Variables b. Primitives c. Statics d. Objects 11. Which of the following keywords is used to define a constant variable? a. Static b. Literal c. Final d. Const 12. Which of the following is an example of an escape character instruction? a. % b. / c. \ d. # 13. Which type of error is encountered if a program performs a division by zero? a. Logic b. Syntax c. Run-time d. Pointer 14. An error in spelling or punctuation in a program is called a

Upload: vuongkien

Post on 23-Apr-2018

217 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: FBLA Computer Science C++ Test · Web viewWhich of the following converts program source code into machine language? C An assembler b. A linker c. A compiler d. An interpreter Object

2004 C++ Programming Page 1Mark the correct answer on your Scantron sheet for each of the following questions.1. Who invented a calculating machine that runs on electricity and whose company eventually became known as IBM?

a. Aiken b. Eckert c. Hollerith d. Babbage

2. The first electronic computer which was completed in 1946 was called the a. Mark I. b. ENIAC. c. Difference Engine. d. UNIVAC.

3. What invention replaced vacuum tubes, allowing computers to become smaller and faster? a. Transistors b. Punch cards c. CPU d. Magnetic tapes

4. Blocks of silicon with logic circuits etched into their surfaces are called a. punch cards. b. transistors. c. microfibers. d. chips.

5. Which of the following converts program source code into machine language? a. An assembler b. A linker c. A compiler d. An interpreter

6. Object code is a. a machine language code produced by the compiling process. b. the actual program written in English. c. the actual program written in C++. d. the result of the linking process.

7. C++ is a hybrid language which a. combines C with plus plus. b. supports C and BASIC. c. supports object-oriented and procedural programming. d. combines Windows and Macintosh.

8. Which of the following is referred to as “main memory”? a. ROM b. RAM c. CPU d. Auxiliary

9. The binary number 11 is equivalent to what decimal number? a. 2 b. 3 c. 4 d. 111

10. What name is given to the named location in a computer’s memory, which can change during program execution? a. Variables b. Primitives c. Statics d. Objects

11. Which of the following keywords is used to define a constant variable? a. Static b. Literal c. Final d. Const

12. Which of the following is an example of an escape character instruction? a. % b. / c. \ d. #

13. Which type of error is encountered if a program performs a division by zero? a. Logic b. Syntax c. Run-time d. Pointer

14. An error in spelling or punctuation in a program is called a a. logic. b. syntax. c. run-time. d. pointer.

15. Which of the following quantities would be best represented with a boolean type variable? a. The number of tacos ordered b. The average number of tacos sold per day c. Whether the customer wants a soft or hard shell taco d. The middle initial in the manager’s name

16. Which of the following would be best defined as an int rather than a double variable? a. The number of students in a calculus class b. The average grade of a student in a calculus class c. The student’s email address d. The student’s middle initial

17. A special code established to translate numbers, letters, and characters into binary digits is known as a. DOS. b. GUI. c. ASCII. d. HEXADECIMAL.

18. XYZ is most likely which kind of C++ primitive data type, given the following code? XYZ = false;

Page 2: FBLA Computer Science C++ Test · Web viewWhich of the following converts program source code into machine language? C An assembler b. A linker c. A compiler d. An interpreter Object

2004 C++ Programming Page 2if (XYZ == true)

answer = ‘H’; a. int b. char c. bool d. double

19. In question #18, which kind of primitive data type would the answer most likely be? a. int b. char c. bool d. double

20. What is the output produced by the following statement when x is 10? cout << x/5 + 16%x;

a. 3 b. 3.6 c. 8 d. 1.8

21. What is the output produced by the following statement when x is 2003? cout << (x%10)/10;

a. 0 b. 3 c. 20 d. 200

22. Nonexecutable statements used to make a program more readable are called a a. comment. b. constant . c. coupling. d. postcondition.

23. Which statement is legal given the following definition? const double PI = 3.1416;

a. PI = PI *10000; b. PI = 3.14; c. cout << PI; d. All are legal.

24. What is the output of the following code? cout.setf(ios::fixed);cout.precision(4);cout<< 12.34567;

a. 12.34; b. 12.35; c. 12.3456; d. 12.3457;

25. A sequence of characters is called a(n) a. String. b. Constant. c. Keyword. d. Concatenation.

26. Program flow control is accomplished with a condition statement which evaluates to either a true or false statement and is called a(n) a. operator. b. relational. c. boolean. d. compound.

27. An IF that contains another IF is called a. nested. b. compound. c. advanced. d. else.

28. The break statement a. immediately terminates a program. b. causes the program go into an infinite loop. c. immediately terminates a loop. d. is a special interpreter command.

29. To what statement is the following statement C++ command equivalent? S *= x;

a. S = S * x; b. S = x * x; c. x = S * x; d. x = S * S;

30. What is the output produced by the following segment of code? for (int i = 5; i >= 1; i-=2)

cout << i ;a. 531 b. 5310 c. 135 d. 31-1

31. The major difference between a while loop and a do-while loop is a. the while loop can execute the body of its code more times.b. the while loop always executes its code at least once.c. the do-while loop always executes its code at least once.

Page 3: FBLA Computer Science C++ Test · Web viewWhich of the following converts program source code into machine language? C An assembler b. A linker c. A compiler d. An interpreter Object

2004 C++ Programming Page 3d. there is no difference; they are identical.

32. What is the output produced by the following segment of code? for (int i = 1; i < 5; i++)

cout << i ;a. 1234 b. 12345 c. 2345 d. 012345

33. What is the output produced by the following segment of code? for(int i=3; i<=5; i++);

cout << i ;a. 345 b. 34 c. 5 d. 6

34. What is the output produced by the following segment of code? String A = "Jim", B = “Hi There”;

cout << B + “ “ + A ;a. Jim Hi There b. Hi There Jim c. Hi ThereJim d. Cannot add Strings in C++

35. Which of the following symbols is used to represent a logical OR operator? a. || b. ++ c. && d. OR

36. What is the output produced by the following segment of code? String A= "123", B= "456";cout<< B-A;

a. 456-123 b. 123-456 c. 333 d. Strings cannot be subtracted.

37. What is the output produced by the following segment of code? int x = 100;int y = 200;if (x == y)

cout << "A";else if (x < y)

cout << "B";else if (x != y)

cout << "C";a. BC b. B c. AB d. C

38. What is the output produced by the following segment of code? for ( int i = 1; i < 10; i += 2)

cout << i << ‘ ‘;a. 1 3 5 7 9 11 b. 2 3 4 5 6 7 8 9 10 c. 2 4 6 8 10 d. 1 3 5 7 9

39. Which of the following best describes a function’s parameters? a. They can be value arguments. b. They can be default arguments. c. They can be reference arguments. d. They can be all of the above.

40. Which of the following can be returned by a function through a return statement? a. Two long values b. Two int values c. A String value d. Three boolean values

41. Using the same name for two different functions is called a. incrementing. b. overloading. c. overriding. d. illegal, because two functions cannot have the same name.

Page 4: FBLA Computer Science C++ Test · Web viewWhich of the following converts program source code into machine language? C An assembler b. A linker c. A compiler d. An interpreter Object

2004 C++ Programming Page 442. Which type of function performs some action and returns no result?

a. long b. char c. bool d. void

43. What are the characteristics of the parameters in the following function? void MandM( int &one, int &other ){

int t = one;one = other;other = t;

}a. They are formatted parameters. b. They are reference parameters. c. They are value parameters. d. They are actual parameters.

44. What kind of error would be encountered when accessing the 101st item in an array defined to consist of 100 items? a. Logic error b. Syntax error c. Range bound error d. Invalid range error

45. A type of indexing used when the keys are variable-length character strings is called a(n) a. rear pointer. b. modularity. c. index sort. d. trie index.

46. A two-dimensional array in C++ is called a a. typedef. b. matrix. c. struct. d. constructor.

47. What is the output produced by the following segment of code? int X = 2;switch (X) {

case 1: cout << “Square ”;break;case 2: cout << “Pants ”;case 3: cout << “Bob ”;break;default: cout << “invalid value”; break;

}a. Pants b. Square Pants Bob c. Pants Bob d. Bob

48. What is the output produced by the following segment of code? int X = 2;switch (X) {

case 1: cout << “Square ”;break;case 2: cout << “Pants ”; break;case 3: cout << “Bob ”;break;default: cout << “invalid value”; break;

}a. Pants b. Square Pants Bob c. Pants Bob d. Bob

49. What is the output produced by the following segment of code? int X = -2;switch (X) {

case 1: cout << “Square ”;case 2: cout << “Pants ”;case 3: cout << “Bob ”;default: cout << “invalid value”; break;

}a. an error will occur b. Square Pants Bob c. Pants Bob d. invalid value

50. An abstract data type consists of a. a class of objects. b. a defined set of properties of objects. c. a set of operations for processing objects. d. all of the above.

51. A stylized half-English, half-code language written in English, but suggesting C++ code is called a. pseudocode. b. big-O notation. c. assembly. d. postconditional.

Page 5: FBLA Computer Science C++ Test · Web viewWhich of the following converts program source code into machine language? C An assembler b. A linker c. A compiler d. An interpreter Object

2004 C++ Programming Page 552. Which of the following is not true about an initializer list?

a. They give initial values to const data members. b. They are used to construct data members that are objects. c. They can be used with any function and a constructor. d. They are invoked when objects of a struct are declared.

53. Data members declared in the private section of class are a. accessible only by member functions. b. accessible only by non-member functions. c. accessible by any function that declares an object of that class. d. never accessible.

54. Which of the following is not true about struct constructor member functions? a. The constructor member function must have the same name as the name of the struct.b. The constructor member function can be used to initialize const data members.c. The constructor member function must be called explicitly when a struct type is used.d. All are true

55. Member functions that are declared const a. cannot be changed by the programmer. b. can be called for objects that have been declared as const. c. can modify data members in the object. d. can only contain const data.

56. A default constructor a. requires no arguments. b. is called for every object declared. c. must have arguments for every data member in the class. d. returns an int indicating whether the constructor succeeded or not.

57. Which of the following is true about constructor member functions? a. All constructors are to be called for all objects of that class.b. All constructors are automatically called at the start of a program.c. All constructors are automatically called whenever an object is defined.d. Constructors are not needed of a class.

58. Objects are usually passed as reference parameters because a. there is no other way to perform the passing operation.b. reference parameters make a local copy of the object.c. reference parameters reduce the time and memory required in passing the object.d. objects are always required to be modified by the methods.

59. Which of the following is not true about classes? a. They are used to instantiate objects. b. Properties of classes include member functions. c. They are used to define file streaming. d. They can be included in a library.

60. Parsing involves the conversion of an expression from a. infix to prefix notation. b. infix to postfix notation. c. prefix to postfix notation. d. prefix to infix notation.

61. Two criteria used in selecting an algorithm for a given task are a. time and money. b. time and algebraic order of operations. c. time and space efficiency. d. space and algebraic order of operations.

62. A searching method that repeatedly references the midpoint of an array is a(n) a. binary algorithm. b. quicksort algorithm. c. bubble algorithm. d. insertion algorithm.

63. Which is not true about the various kinds of sorts? a. The insertions sort normally uses a looping process.b. The quicksort normally uses a looping process.c. The selection and merge sorts normally use a recursive process.d. The merge sort normally uses a looping process.

Page 6: FBLA Computer Science C++ Test · Web viewWhich of the following converts program source code into machine language? C An assembler b. A linker c. A compiler d. An interpreter Object

2004 C++ Programming Page 6

64. A method of hashing in cases where the key is not an integer value is called a. folding. b. heaping. c. balancing. d. threading.

65. A dynamic data structure in which access can only be made from one end and removed from the other end is called a a. stack. b. queue. c. ragged array. d. stub.

66. A condition when unused dynamic storage to a heap is not returned is called a. polymorphism. b. memory leakage. c. popping. d. blockage.

67. A data structure that allows the user to access different kinds of information (like text, images, sound, video, or applications) by traversing links is called a. hash code. b. grid layout. c. object heaping. d. hypermedia.

68. A technique of avoiding recursion in tree traversal algorithms by turning unused pointers into pointers in order predecessors and successors of a node is called a. tokening. b. threading. c. backtracking. d. merging.

69. Which of the following is not a standard way of traversing a binary tree? a. Preorder b. Postorder c. Inorder d. Outorder

70. Computer scientists study the relationship between an array’s length and its execution time using a. recursion. b. the iterative process. c. a binary search algorithm. d. big-O notation.

71. Which is the maximum number of steps needed for a binary search algorithm to search a sorted list of 255 elements? a. 6 b. 7 c. 8 d. 9

72. The #ifndef and #endif compiler directives a. are used to prevent multiple compilation of library files.b. are used to replace the ordinary if conditional statement.c. are used in implementing default constructors.d. cannot be used in conjunction with a #define statement.

73. Which of the following is used to allocate dynamic memory? a. * b. new c. delete d. NULL

74. The property of one operator symbol or function identifier having many meanings is called a. polymorphism. b. parsing. c. postfix. d. polynomial.

75. The process of hiding implementations details of a data structure is called a. validation. b. encapsulation. c. hashing. d. linear collision.

76. Dynamic memory is destroyed and made available for subsequent reuse by what command? a. hashing b. linear collision c. delete d. new

77. In the graphics environment a single dot, or picture element is called a a. window. b. class. c. mouse. d. pixel.

78. In the graphics environment interface window, labels, buttons, and data entry fields are referred to as a. GUI icons. b. window objects. c. active controls. d. control objects.

79. In the graphics environment, colors can by fine tuned with a. 256 shades of red. b. 256 shades of green. c. 256 shades of blue. d. All of the above

80. Which of the following is not true about graphics-based programming? a. The program window displays only graphics and mouse inputs.b. The program waits for a user to tell the computer what to do.

Page 7: FBLA Computer Science C++ Test · Web viewWhich of the following converts program source code into machine language? C An assembler b. A linker c. A compiler d. An interpreter Object

2004 C++ Programming Page 7c. The program requires event-driven code.d. The program interacts with a user through text displayed on the screen and keystrokes from the user.

81. What is the output of the following segment of code? enum Day {Mon, Tue, Wed, Thu, Fri, Sat, Sun};Day Today = Fri; cout << Today;

a. Fri b. 5 c. 4 d. An error will occur.

82. Which of the following is not a legal C++ statement given the following code? enum Summer {June, July, August};Summer Month = June;

a. for (Month = June; Month <= August; Month++) b. if (Month == June) c. cout << Month; d. All are legal

83. A file with items that are accessed one after the other in the order stored is called a. sequential. b. random. c. reverse order. d. derived.

84. Library functions that are not member functions of a class are called a. overloaded. b. free functions. c. constructors. d. destructors.

85. The rules for interpreting the meaning of a program in a language are called a. sentinel. b. clustering. c. semantics. d. friend class.

86. What is the output produced by the following segment of code? int x = 100;int y = 200;if (x == y)

cout << "A";if (x < y)

cout << "B";if(x != y)

cout << "C";a. BC b. B c. AB d. C

87. Which of the following conditional statements is equivalent to A <B && B < C? a. ( A > B ) || ( B > C ) b. ! (A <= B ) || ! ( B >= C) c. A < C d. ! ( ( A >= B ) || ( B >= C ) )

88. Which of the following is not true about trees? a. They are a data structure that reflects a hierarchical relationship. b. Parent-child terminology is used. c. They are natural recursive structures. d. Each node has, at most, two (2) subnodes.

89. What is the output produced by the following segment of code? int x = 6;do {

cout << "*";x -= 2;

} while (x > 1);cout << "done";

a. ***done b. *done c. done d. An infinite loop of asterisks is displayed.

90. Which of the following big-O values represents a quadratic algorithm? a. O(n log n) b. O(n3) c. O(n2) d. O(2n)

91. What is the output produced by the following segment of code? int x = 6;do {

cout << "*";x += 2;

Page 8: FBLA Computer Science C++ Test · Web viewWhich of the following converts program source code into machine language? C An assembler b. A linker c. A compiler d. An interpreter Object

2004 C++ Programming Page 8} while (x != 1);cout << "done";

a. ***done b. *done c. done d. An infinite loop of asterisks is displayed.

92. What is the output produced by the following segment of code? int x = 0, y = 0;while (y <= 5){

y += 2;x -= y;

}cout << y << " " << x;

a. -6 6 b. 6 -6 c. 6 -8 d. 6 -12

93. What is the output produced by the following segment of code? int x = 6, y = 0;while (y <= 5);{

y += x;y -= 2;x += 2;

}cout << y << " " << x;

a. 4 8 b. 6 0 c. 6 2 d. 10 10

94. Which of the following correctly prints all the elements of an array List? a. for (int i = 0; i<List.length(); i++)

cout << List[i];b. for (int i = 1; i<=List.length(); i++)

cout << List[i];c. for (int i = 0; i<=List.length(); i++)

cout << List[i];d. for (int i = 1; i<List.length(); i++)

cout << List[i];

95. What is returned by the call to ComputeTheAnswerTo(13); given the following definition? void ComputeTheAnswerTo (int N){

cout << N << “ * “;if (N > 0) {

ComputeTheAnswerTo(N/3);cout << N << “ * “;

}}

a. 13 * 4 * 1 * 0 * b. 13 * 4 * 1 * 1 * 4 * 13 * c. 13 * 4 * 1 * 0 * 1 * 4 * 13 * d. an error will occur.

96. What is returned by the call to ComputeValue(11)? int ComputeValue (int N){

if (N == 0)return(0);

elsereturn(N%2 + ComputeValue(N/2));

}a. 0 b. 2 c. 3 d. 4

Page 9: FBLA Computer Science C++ Test · Web viewWhich of the following converts program source code into machine language? C An assembler b. A linker c. A compiler d. An interpreter Object

2004 C++ Programming Page 997. Which of the following is not a C++ language reserve word?

a. float b. this c. try d. unprotected

98. Which of the following is not an application of binary trees? a. Leaf nodes b. One-key tables c. Priority queues d. Algebraic expressions

99. A two-dimensional vector and a one-key table of one-key tables are two ways of implementing a. leaf nodes. b. a two-key table. c. priority queues. d. a dynamic memory list.

Page 10: FBLA Computer Science C++ Test · Web viewWhich of the following converts program source code into machine language? C An assembler b. A linker c. A compiler d. An interpreter Object

2004 C++ Programming Page 102003 FBLA C++ PROGRAMMING KEY

ANSWER ANSWER ANSWER ANSWER1. C 26. C 51. A 76. C2. B 27. A 52. C 77. D3. A 28. C 53. A 78. B4. D 29. A 54. C 79. D5. C 30. A 55. B 80. D6. A 31. C 56. A 81. C7. C 32. A 57. B 82. D8. B 33. D 58. B 83. A9. B 34. B 59. C 84. B10. A 35. A 60. B 85. C11. D 36. D 61. C 86. A12. C 37. B 62. A 87. D13. C 38. D 63. B 88. D14. B 39. D 64. A 89. A15. C 40. C 65. B 90. C16. A 41. B 66. B 91. D17. C 42. D 67. D 92. D18. C 43. B 68. B 93. D19. B 44. C 69. D 94. A20. C 45. D 70. D 95. A21. A 46. B 71. C 96. C22. A 47. A 72. A 97. D23. C 48. A 73. B 98. A24. D 49. D 74. A 99. B25. a 50. D 75. B 100.