wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Computer Science 1 2nd Sem. Final Exam Review

Total questions: 80

Worksheet time: 40mins

Name
Class
Date
1.
A ________ algorithm is a method of locating a specific item of information in a larger collection of data.
a)
sort
b)
search
c)
standard
d)
linear
2.
The advantage of a linear search is its ____________.
a)
complexity
b)
efficiency
c)
simplicity
d)
None of these
3.
A(n) ________ search is more efficient than a(n) ________ search
a)
character, string
b)
integer, double
c)
binary, linear
d)
linear, binary
4.
A binary search begins with the _________ element of an array.
a)
first
b)
last
c)
largest
d)
middle
5.
The _________ sort usually performs fewer exchanges than the ________ sort.
a)
bubble, selection
b)
binary, linear
c)
selection, bubble
d)
ANSI, ASCII
6.
Array elements must be _________ before a binary search can be performed.
a)
summed
b)
set to zero
c)
sorted
d)
positive numbers
7.
A(n) ________ search uses a loop to sequentially step through an array.
a)
binary
b)
unary
c)
linear
d)
relative
8.
Data that is sorted in ascending order is ordered
a)
from lowest to highest value
b)
from highest to lowest value
c)
always with a binary sort algorithm
d)
always with a linear sort algorithm
9.
When an array is sorted from highest to lowest, it is said to be in _____ order.
a)
reverse
b)
forward
c)
descending
d)
ascending
10.
The _________ is adequate for searching through small arrays.
a)
binary search
b)
linear search
c)
unary search
d)
bubble sort
11.
___________ algorithms are used to arrange random data into some order.
a)
Standard search
b)
Linear
c)
Sorting
d)
Binary search
12.
Unlike regular variables, these can hold multiple values.
a)
constants
b)
named constants
c)
arrays
d)
floating-point variables
13.
The individual values contained in array are known as
a)
parts
b)
elements
c)
numbers
d)
constants
14.
Which of the following is a valid C++ array definition?
a)
int array[0];
b)
float $payments[10];
c)
void numbers[5];
d)
int array[10];
15.
By using the same ________ you can build relationships between data stored in two or more arrays.
a)
array name
b)
data
c)
subscript
d)
arguments
16.
The name of an array stores the __________ of the first array element.
a)
memory address
b)
value
c)
element number
d)
data type
17.
A two-dimensional array is like ______________ put together.
a)
an array and a function
b)
several identical arrays
c)
two functions
d)
two arrays of different types
18.
A two-dimensional array can be viewed as ___________ and _____________.
a)
rows, columns
b)
arguments, parameters
c)
increments, decrements
d)
All of these
19.
If you leave out the size declarator in an array definition:
a)
you must furnish an initialization list
b)
you are not required to initialize the array elements
c)
all array elements default to zero values
d)
your array will contain no elements
20.
When writing functions that accept multi-dimensional arrays as arguments, _______________ must be explicitly stated in the parameter list.
a)
all dimensions
b)
all but the first dimension
c)
the size declarator of the first dimension
d)
all element values
21.
An array can store a group of values, but the values must be
a)
the same data type
b)
each of a different data type
c)
constants
d)
integers
22.
An array's size declarator must be a(n)_________ with a value greater than _________.
a)
number, one
b)
number, zero
c)
constant integer expression, zero
d)
variable, -1
23.
Subscript numbering in C++
a)
can be set at runtime
b)
can begin with a programmer-defined value
c)
varies from program to program
d)
begins with zero
24.
Arrays may be ___________ at the time they are __________.
a)
resized, executed
b)
re-scoped, deleted
c)
initialized, declared
d)
pre-compiled, typecast
25.
An array can easily be stepped through by using a
a)
for loop
b)
reference variable
c)
named constant
d)
null value
26.
To assign the contents of one array to another, you must use
a)
the assignment operator with the array names
b)
the equality operator with the array names
c)
a loop to assign the elements of one array to the other array
d)
Any of these
27.
To pass an array as an argument to a function, pass the _________ of the array.
a)
contents
b)
size, expressed as an integer
c)
name
d)
value of the first element
28.
A two-dimensional array can have elements of _________ data type(s).
a)
one
b)
two
c)
four
d)
Any of these
29.
A two-dimensional array of characters can contain
a)
strings of the same length
b)
strings of different lengths
c)
uninitialized elements
d)
All of these
30.
A(n) ____________ can be used to specify the starting values of an array.
a)
initialization list
b)
array name
c)
subscript
d)
element
31.
The ______________ is automatically appended to a character array when it is initialized with a string constant.
a)
array name
b)
number of elements
c)
value of the first element
d)
null terminator
32.
An array with no elements is
a)
legal in C++
b)
illegal in C++
c)
automatically furnished one element, with a value of zero
d)
automatically furnished one value -- the null terminator
33.
An array of string objects that will hold 5 names would be declared using which statement?
a)
string names[5];
b)
string names(5);
c)
string names5;
d)
String[5] names;
34.
It is __________ to pass an argument to a function that contains an individual array element, such as numbers[3].
a)
illegal in C++
b)
legal in C++
c)
not recommended by the ANSI committee
d)
not good programming practice
35.
How many elements does the following array have?   int bugs[1000];
a)
1000
b)
999
c)
1001
d)
Cannot tell from the code
36.
Which statement correctly defines a vector object for holding integers?
a)
vector v<int>;
b)
int vector v;
c)
int<vector> v;
d)
vector<int> v;
37.
This vector function is used to insert an item into a vector.
a)
insert_item
b)
add_item
c)
store
d)
push_back
38.
This vector function returns the number of elements in a vector.
a)
size
b)
num_elements
c)
elements
d)
length
39.
This vector function removes an item from a vector.
a)
remove_item
b)
delete_item
c)
erase
d)
pop_back
40.
This vector function returns true if the vector has no elements.
a)
has_no_elements
b)
null_size
c)
empty
d)
is_empty
41.
This is a collection of statements that performs a specific task.
a)
infinite loop
b)
variable
c)
constant
d)
function
42.
A function __________ contains the statements that make up the function.
a)
definition
b)
prototype
c)
call
d)
expression
43.
A function can have zero to many parameters, and it can return this many values.
a)
zero to many
b)
no
c)
only one
d)
a maximum of ten
44.
A function is executed when it is
a)
defined
b)
prototyped
c)
declared
d)
called
45.
In a function header, you must furnish
a)
data type(s) of the parameters
b)
data type of the return value
c)
the name of function
d)
All of these
46.
Functions are ideal for use in menu-driven programs.  When a user selects a menu item, the program can ________ the appropriate function.
a)
call
b)
prototype
c)
define
d)
declare
47.
This type of variable is defined inside a function and is not accessible outside the function.
a)
global
b)
reference
c)
local
d)
counter
48.
The value in this type of local variable persists between function calls.
a)
global
b)
internal
c)
static
d)
dynamic
49.
These types of arguments are passed to parameters automatically if no argument is provided in the function call.
a)
Local
b)
Default
c)
Global
d)
Relational
50.
When used as parameters, these types of variables allow a function to access the parameter's original argument.
a)
reference
b)
floating-point
c)
counter
d)
undeclared
51.
This statement causes a function to end.
a)
end
b)
terminate
c)
return
d)
release
52.
_________ functions may have the same name, as long as their parameter lists are different.
a)
Only two
b)
Two or more
c)
Zero
d)
Un-prototyped
53.
This function causes a program to terminate, regardless of which function or control mechanism is executing.
a)
terminate()
b)
return()
c)
continue()
d)
exit()
54.
This is a statement that causes a function to execute.
a)
for loop
b)
do-while loop
c)
function prototype
d)
function call
55.
It is a good programming practice to ____________ your functions by writing comments that describe what they do.
a)
execute
b)
document
c)
eliminate
d)
prototype
56.
A(n) _________ is information that is passed to a function, and a(n) _________ is information that is received by a function.
a)
function call, function header
b)
parameter, argument
c)
argument, parameter
d)
prototype, header
57.
Which of the following statements about global variables is true?
a)
A global variable is accessible only to the main function.
b)
A global variable is declared in the highest-level block in which it is used.
c)
A global variable can have the same name as a variable that is declared locally within a function.
d)
If a function contains a local variable with the same name as a global variable, the global variable's name takes precedence within the function.
58.
A function __________ eliminates the need to place a function definition before all calls to the function.
a)
header
b)
prototype
c)
argument
d)
parameter
59.
A ___________ variable is declared outside all functions.
a)
local
b)
global
c)
floating-point
d)
counter
60.
If a function is called more than once in a program, the values stored in the function's local variables do not _________ between function calls.
a)
persist
b)
execute
c)
communicate
d)
change
61.
A(n) _________ argument is passed to a parameter when the actual argument is left out of the function call.
a)
false
b)
true
c)
null
d)
default
62.
If a function does not have a prototype, default arguments may be specified in the function ___________.
a)
call
b)
header
c)
execution
d)
   
return type
63.
EXIT_FAILURE and __________ are named constants that may be used to indicate success or failure when the exit() function is called.
a)
EXIT_TERMINATE
b)
EXIT_
c)
EXIT_OK
d)
RETURN_OK
64.
The value in a(n) _______ variable persists between function calls.
a)
dynamic
b)
local
c)
counter
d)
static local
65.
This is a dummy function that is called instead of the actual function it represents.
a)
main function
b)
stub
c)
driver
d)
overloaded function
66.
The amount of memory used by an array depends upon the array's data type and the number of elements in the array.
a)
True
b)
False
67.
C++ limits the number of array dimensions to two.
a)
True
b)
False
68.
An individual array element can be processed like any other type of C++ variable.
a)
True
b)
False
69.
Although two-dimensional arrays are a novel idea, there is no known way to pass one to a function.
a)
True
b)
False
70.
Each individual element of an array can be accessed by the array name and an element number, called a subscript.
a)
True
b)
False
71.
If an array is partially initialized, the uninitialized elements will be set to zero.
a)
True
b)
False
72.
A vector object automatically expands in size to accommodate the items stored in it.  
a)
True
b)
False
73.
A parameter is a special-purpose variable that is declared inside the parentheses of a function definition.
a)
True
b)
False
74.
A local variable and a global variable may not have the same name within the same program
a)
True
b)
False
75.
A static variable that is defined within a function is initialized only once, the first time the function is called.
a)
True
b)
False
76.
One reason for using functions is to break programs into manageable units, or modules.
a)
True
b)
False
77.
You must furnish an argument with a function call.
a)
True
b)
False
78.
Global variables are initialized to zero by default.
a)
True
b)
False
79.
It is not considered good programming practice to declare all of your variables globally.
a)
True
b)
False
80.
In the average case, an item is just as likely to be found near the beginning of an array as near the end.
a)
True
b)
False