Computer Science II Final Exam
Graded A+
1) ADT stands for:
A) Algorithm Dependent Template
B) Algorithm Driven Template
C) Abstract Data Type
D) Automatic Data Type
E) None of these - ANSWER-C) Abstract Data Type
1) Data stored here disappears once the program stops running or the computer is
powered down.
A) on a CD
B) in RAM
C) on a backup tape
D) on the disk drive
E) None of these - ANSWER-B) in RAM
1) The ________, also known as the address operator, returns the memory address of
a variable.
A) asterisk ( * )
B) ampersand ( & )
C) percent sign (%)
D) exclamation point ( ! )
E) None of these - ANSWER-B) ampersand ( & )
10) Look at the following statement:
sum += *array++;
This statement ________.
A) is illegal in C++
B) will always result in a compiler error
C) assigns the dereferenced pointer's value, then increments the pointer's address
D) increments the dereferenced pointer's value by one, then assigns that value
E) None of these - ANSWER-C) assigns the dereferenced pointer's value, then
increments the pointer's address
10) The list container provided by the Standard Template Library is a template version
of a ________.
A) singly-linked list
B) doubly-linked list
C) circular-linked list
,D) backward-linked list
E) None of these - ANSWER-B) doubly-linked list
10) This member function reads a single character from a file.
A) read
B) get
C) put
D) input
E) None of these - ANSWER-B) get
11) Appending a node means adding it to the end of a list, and ________ a node means
putting a new node in the list, but not necessarily at the end.
A) concatenating
B) popping
C) clamping
D) inserting
E) None of these - ANSWER-D) inserting
11) This member function can be used to store binary data to a file.
A) binary.out
B) write
C) put <<
D) dataout(binary)
E) None of these - ANSWER-B) write
11) Use the delete operator only on pointers that were ________.
A) never used
B) not correctly initialized
C) created with the new operator
D) dereferenced inappropriately
E) None of these - ANSWER-C) created with the new operator
12) A function may return a pointer, but the programmer must ensure that the pointer
________.
A) still points to a valid object after the function ends
B) has not been assigned an address
C) was received as a parameter by the function
D) has not previously been returned by another function
E) None of these - ANSWER-A) still points to a valid object after the function ends
12) In a circular-linked list, the last node points to the ________.
A) head pointer
B) tail pointer
C) first node
D) closing curly brace of the original structure declaration
E) None of these - ANSWER-C) first node
, 12) To access files from a C++ program, you must use this directive:
A) #include<fileaccess>
B) #include <filestream>
C) #include <fstream>
D) #include <iostream>
E) None of these - ANSWER-C) #include <fstream>
13) If new data needs to be added to a linked list, the program simply ________ and
inserts it into the series.
A) allocates another node
B) removes a node
C) borrows a node from the compiler
D) Either B or C
E) None of these - ANSWER-A) allocates another node
13) To set up a file to perform file I/O, you must declare:
A) at least one variable, the contents of which will be written to the file
B) one or more file stream objects
C) a string object to store the file contents
D) All of these
E) None of these - ANSWER-B) one or more file stream objects
13) Which of the following statements is not valid C++ code?
A) int ptr = &num1;
B) int ptr = int *num1;
C) float num1 = &ptr2;
D) All of these are valid.
E) All of these are invalid. - ANSWER-E) All of these are invalid.
14) ofstream, ifstream, and fstream are:
A) header files
B) libraries
C) data types
D) string arrays
E) None of these - ANSWER-C) data types
14) The advantage a linked list has over a vector is:
A) A linked list can dynamically shrink or grow, and a vector cannot
B) A linked list is smaller than a vector
C) A node can be inserted into or removed from a linked list faster than from a vector
D) Data removal and insertion are more accurate with a linked list than with a vector
E) None of these - ANSWER-C) A node can be inserted into or removed from a linked
list faster than from a vector
Graded A+
1) ADT stands for:
A) Algorithm Dependent Template
B) Algorithm Driven Template
C) Abstract Data Type
D) Automatic Data Type
E) None of these - ANSWER-C) Abstract Data Type
1) Data stored here disappears once the program stops running or the computer is
powered down.
A) on a CD
B) in RAM
C) on a backup tape
D) on the disk drive
E) None of these - ANSWER-B) in RAM
1) The ________, also known as the address operator, returns the memory address of
a variable.
A) asterisk ( * )
B) ampersand ( & )
C) percent sign (%)
D) exclamation point ( ! )
E) None of these - ANSWER-B) ampersand ( & )
10) Look at the following statement:
sum += *array++;
This statement ________.
A) is illegal in C++
B) will always result in a compiler error
C) assigns the dereferenced pointer's value, then increments the pointer's address
D) increments the dereferenced pointer's value by one, then assigns that value
E) None of these - ANSWER-C) assigns the dereferenced pointer's value, then
increments the pointer's address
10) The list container provided by the Standard Template Library is a template version
of a ________.
A) singly-linked list
B) doubly-linked list
C) circular-linked list
,D) backward-linked list
E) None of these - ANSWER-B) doubly-linked list
10) This member function reads a single character from a file.
A) read
B) get
C) put
D) input
E) None of these - ANSWER-B) get
11) Appending a node means adding it to the end of a list, and ________ a node means
putting a new node in the list, but not necessarily at the end.
A) concatenating
B) popping
C) clamping
D) inserting
E) None of these - ANSWER-D) inserting
11) This member function can be used to store binary data to a file.
A) binary.out
B) write
C) put <<
D) dataout(binary)
E) None of these - ANSWER-B) write
11) Use the delete operator only on pointers that were ________.
A) never used
B) not correctly initialized
C) created with the new operator
D) dereferenced inappropriately
E) None of these - ANSWER-C) created with the new operator
12) A function may return a pointer, but the programmer must ensure that the pointer
________.
A) still points to a valid object after the function ends
B) has not been assigned an address
C) was received as a parameter by the function
D) has not previously been returned by another function
E) None of these - ANSWER-A) still points to a valid object after the function ends
12) In a circular-linked list, the last node points to the ________.
A) head pointer
B) tail pointer
C) first node
D) closing curly brace of the original structure declaration
E) None of these - ANSWER-C) first node
, 12) To access files from a C++ program, you must use this directive:
A) #include<fileaccess>
B) #include <filestream>
C) #include <fstream>
D) #include <iostream>
E) None of these - ANSWER-C) #include <fstream>
13) If new data needs to be added to a linked list, the program simply ________ and
inserts it into the series.
A) allocates another node
B) removes a node
C) borrows a node from the compiler
D) Either B or C
E) None of these - ANSWER-A) allocates another node
13) To set up a file to perform file I/O, you must declare:
A) at least one variable, the contents of which will be written to the file
B) one or more file stream objects
C) a string object to store the file contents
D) All of these
E) None of these - ANSWER-B) one or more file stream objects
13) Which of the following statements is not valid C++ code?
A) int ptr = &num1;
B) int ptr = int *num1;
C) float num1 = &ptr2;
D) All of these are valid.
E) All of these are invalid. - ANSWER-E) All of these are invalid.
14) ofstream, ifstream, and fstream are:
A) header files
B) libraries
C) data types
D) string arrays
E) None of these - ANSWER-C) data types
14) The advantage a linked list has over a vector is:
A) A linked list can dynamically shrink or grow, and a vector cannot
B) A linked list is smaller than a vector
C) A node can be inserted into or removed from a linked list faster than from a vector
D) Data removal and insertion are more accurate with a linked list than with a vector
E) None of these - ANSWER-C) A node can be inserted into or removed from a linked
list faster than from a vector