NEW
Font size
WorksheetsIT101-1_FINALS_MULTIPLECHOICE
Total questions: 62
Worksheet time: 31mins
Which of the following best describes an array?
A list of variables with different names and data types
A single variable that can hold multiple data types
A series or list of variables in memory, all sharing the same name and data type
A special type of method
In an array, all variables share the same name, but each individual item has a different:
Data type
Subscript
Global scope
Memory address
What is the position number of an item in an array called?
Element
Subscript or index
Data type
Array name
Array subscripts are always a sequence of:
Integers
Strings
Characters
Floating-point numbers
What is an individual item within an array called?
Element
Index
Module
Flag
In computer memory, array elements are stored in _______ locations.
Random
Contiguous
Parallel
Global
The "size" of an array refers to:
The data type of its elements
The number of bytes it occupies
The number of elements it will hold
The value of its first element
If you declare an array num scores[5], what is the subscript of the first element?
scores[1]
scores[0]
scores
scores[5]
Given the declaration num scores[5], which of the following subscripts is "out of bounds"?
0
2
4
5
Using an array with a variable as a subscript, such as count[dep], is an efficient way to replace:
A single if statement
A series of nested decisions
A for loop
A method call
If you have an array num count[6] = 0, 0, 0, 0, 0, 0 and a variable num dep = 2, what does the statement count[dep] = count[dep] + 1 do?
It increments the value of dep to 3.
It increments the value of the first element (count[0]) to 1.
It increments the value of the third element (count[2]) to 1.
It causes an out-of-bounds error.
Declaring a named numeric constant (e.g., SIZE = 10) to define the size of an array helps to avoid:
"Magic numbers"
Syntax errors
Needing to use a loop
Parallel arrays
The declaration string MONTH[12] = "January", "February", ... is an example of using constants as:
The size of the array
Array element values
Array subscripts
A flag
A variable, often a boolean or string, that is set to indicate whether an event (like finding a value in an array) has occurred is called a:
Counter
Subscript
Flag
Constant
When starting a search from the beginning of an array, the subscript variable is typically initialized to:
0
1
-1
The size of the array
What are parallel arrays?
Two arrays that have the same name but different sizes.
Two arrays stored in the same memory location.
Two or more arrays where each element in one is associated with the element in the same relative position in the other(s).
Arrays that can only be processed using a for loop.
You have two parallel arrays: num VALID_ITEM[3] = 101, 102, 103 and num VALID_PRICE[3] = 5.00, 7.50, 6.00. What is the price of item 102?
5.00
7.50
6.00
102
In an array search, stopping the loop as soon as the desired value is found is a technique to:
Improve search efficiency
Make the array larger
Avoid using a flag
What is the main purpose of using a search condition like 'while sub < SIZE AND foundIt = "N"' in an array search?
Improve search efficiency
Prevent out-of-bounds errors
Create parallel arrays
A loop that will never end
Which of the following best describes a loop condition that stops when the item is found or the array ends?
A loop that will never end
An efficient search that stops when the item is found or the array ends
A range match
A way to create parallel arrays
Given parallel arrays 'num QUAN_LIMIT[4] = 0, 9, 13, 26' and 'num DISCOUNT[4] = 0, 0.10, 0.15, 0.20', what is this technique used for?
Search an array for an exact value
Sort an array
Search an array for a range match
Randomize array elements
What is the error called when a subscript is used outside the acceptable range for an array?
Out-of-bounds error
Encapsulation error
Ambiguity error
Syntax error
Accessing a memory location outside of the array by using an invalid subscript is what type of error?
A compile-time error
A syntax error
A logical error
A hardware error
Which loop structure is especially convenient for processing every element in an array?
while loop
if-then-else
for loop
switch statement
If an array is declared with 'num SIZE = 10', for a loop to process every element, the loop should run from 'dep = 0' to:
SIZE
SIZE - 1
SIZE + 1
1
Given 'num someVals[3] = 25, 36, 47', what is the value of 'someVals[1]'?
25
36
47
Out of bounds
If you use a variable as a subscript in an array, what must it be?
A string
Numeric with no decimal places
A constant
A boolean
The logic for a mail-order business that checks if an item number is valid (e.g., 106, 108, 307) would likely involve which process?
A range match
Searching an array for an exact match
Incrementing a counter array
Overloading the array
If an array 'data' has 50 elements, what is the subscript of the last element?
50
49
51
data[last]
To avoid 'magic numbers' in loops that process an array, what should you use?
Hard-coded value (e.g., while x < 100)
Named constant (e.g., while x < SIZE)
Method
Flag
Which of the following is NOT a way constants are typically used with arrays?
To hold the size of an array
As the array's element values
As an array subscript
As a replacement for the array's name
A method is a program module containing a series of statements that:
Are executed in sequence to perform a specific task
Are used only for array processing
Must always return a value
Can only be called once
What is the primary purpose of a method in programming?
Carry out a task
Must return a numeric value
Can only be called once
Defines global variables
What is the act of calling a method also known as?
Invoking the method
Declaring the method
Encapsulating the method
Hiding the method
A program that calls a method is known as the method's:
Parent
Client
Module
Header
Which of the following is NOT included in a method header?
The return type
The method name
The parameter list
The method's implementation (the statements)
Where are the statements that carry out a method's tasks contained?
Method header
Method body
Return statement
Parameter list
According to structured programming principles, a method should ideally have only one:
Parameter
Local variable
Return statement, as the last statement
if statement
A data item declared within a method is _______ to that method.
Global
Local
Encapsulated
Ambiguous
When a data item is known to all of a program's methods, it is a:
Global data item
Local data item
Parameter
Return value
A variable is said to be 'in scope' when it:
Is global
Is out of bounds
Exists and is usable
Has been returned by a method
When does a local variable 'go out of scope'?
When the method in which it was declared ends
When a global variable with the same name is declared
After it is used once
Never, it is permanent
Which of the following is NOT a benefit of modularization?
It provides abstraction, making the 'big picture' easier to see
It allows multiple programmers to work on a problem
It allows you to reuse your work
It guarantees all variable names are unique without programmer effort
What is the concept of completely containing data within a method, accessible only to that method, known as?
Overloading
Encapsulation or information hiding
Passing by reference
Ambiguity
In a method call, the value passed in parentheses is the _______, while the variable in the method header that receives the value is the _______.
argument; parameter
parameter; argument
local; global
global; local
When you pass a variable 'by value,' what is sent to the method?
The variable's memory address
A copy of the variable's value
The variable's name
Nothing
If a variable myAge = 20 is passed by value to a method, and the method changes its parameter's value to 50, what is the value of myAge after the method call?
20
50
70
An error occurs
When a method receives the memory address of the data passed to it, the data was:
Passed by value
Passed by reference
A constant
A local variable
How is a single element of an array (e.g., myArray[3]) passed to a method?
By reference
By value
It cannot be passed
As a global variable
How is an entire array passed to a method?
By reference
By value
Each element is passed by value individually
It is copied to a new local array
If you pass an entire array to a method and the method changes the values of its elements, what happens to the original array?
The original array is unchanged.
The original array's elements are permanently changed.
The method creates a copy of the array.
An ambiguity error occurs.
A method with a void return type:
Returns nothing
Returns a zero
Returns a boolean value
Accepts no parameters
The data type specified before the method name in the header, such as num in num getHoursWorked(), is the:
Method's type, which indicates its return type
Parameter type
Global type
Overloaded type
The value used in a return statement must match the:
Data type of the first parameter
Method's return type specified in the header
Name of the method
Number of arguments
Writing multiple methods with the same name but different parameter lists is called:
Encapsulation
Ambiguity
Method overloading
Information hiding
Which of the following is a valid overload for the method void printBill(num balance)?
num printBill(num balance)
void printBill(num total)
void printBill(num balance, string message)
void MyPrintBill(num balance)
"Ambiguous methods" occur when:
A method has too many parameters
The compiler cannot determine which overloaded method to use
A method calls itself
A method returns a void type
A program contains these two method headers. What is the result? num calc(num principal, num rate) string calc(num p, num r)
This is valid method overloading.
This is illegal; the compiler cannot tell them apart based on a call like calc(100, 0.05).
This is encapsulation.
This is passing by reference.
A program contains these two method headers. What is the result? void checkValue(num a, string b) void checkValue(string b, num a)
This is valid method overloading.
This is illegal and ambiguous.
This will cause a syntax error.
This is an example of a void return.
Prewritten methods provided by a programming language, such as mathematical functions, are known as:
Built-in methods
Local methods
Ambiguous methods
Overloaded methods
In the method header string getFullName(string first, string last), the method's "type" is:
string
first
last
void
Which of the following is not a benefit of using methods (modularization)?
Provides abstraction
Allows code reuse
Makes a program run faster by using more memory
Allows multiple programmers to work on a problem
