wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

IT101-1_FINALS_MULTIPLECHOICE

Total questions: 62

Worksheet time: 31mins

Name
Class
Date
1.

Which of the following best describes an array?

a)

A list of variables with different names and data types

b)

A single variable that can hold multiple data types

c)

A series or list of variables in memory, all sharing the same name and data type

d)

A special type of method

2.

In an array, all variables share the same name, but each individual item has a different:

a)

Data type

b)

Subscript

c)

Global scope

d)

Memory address

3.

What is the position number of an item in an array called?

a)

Element

b)

Subscript or index

c)

Data type

d)

Array name

4.

Array subscripts are always a sequence of:

a)

Integers

b)

Strings

c)

Characters

d)

Floating-point numbers

5.

What is an individual item within an array called?

a)

Element

b)

Index

c)

Module

d)

Flag

6.

In computer memory, array elements are stored in _______ locations.

a)

Random

b)

Contiguous

c)

Parallel

d)

Global

7.

The "size" of an array refers to:

a)

The data type of its elements

b)

The number of bytes it occupies

c)

The number of elements it will hold

d)

The value of its first element

8.

If you declare an array num scores[5], what is the subscript of the first element?

a)

scores[1]

b)

scores[0]

c)

scores

d)

scores[5]

9.

Given the declaration num scores[5], which of the following subscripts is "out of bounds"?

a)

0

b)

2

c)

4

d)

5

10.

Using an array with a variable as a subscript, such as count[dep], is an efficient way to replace:

a)

A single if statement

b)

A series of nested decisions

c)

A for loop

d)

A method call

11.

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?

a)

It increments the value of dep to 3.

b)

It increments the value of the first element (count[0]) to 1.

c)

It increments the value of the third element (count[2]) to 1.

d)

It causes an out-of-bounds error.

12.

Declaring a named numeric constant (e.g., SIZE = 10) to define the size of an array helps to avoid:

a)

"Magic numbers"

b)

Syntax errors

c)

Needing to use a loop

d)

Parallel arrays

13.

The declaration string MONTH[12] = "January", "February", ... is an example of using constants as:

a)

The size of the array

b)

Array element values

c)

Array subscripts

d)

A flag

14.

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:

a)

Counter

b)

Subscript

c)

Flag

d)

Constant

15.

When starting a search from the beginning of an array, the subscript variable is typically initialized to:

a)

0

b)

1

c)

-1

d)

The size of the array

16.

What are parallel arrays?

a)

Two arrays that have the same name but different sizes.

b)

Two arrays stored in the same memory location.

c)

Two or more arrays where each element in one is associated with the element in the same relative position in the other(s).

d)

Arrays that can only be processed using a for loop.

17.

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?

a)

5.00

b)

7.50

c)

6.00

d)

102

18.

In an array search, stopping the loop as soon as the desired value is found is a technique to:

a)

Improve search efficiency

b)

Make the array larger

c)

Avoid using a flag

19.

What is the main purpose of using a search condition like 'while sub < SIZE AND foundIt = "N"' in an array search?

a)

Improve search efficiency

b)

Prevent out-of-bounds errors

c)

Create parallel arrays

d)

A loop that will never end

20.

Which of the following best describes a loop condition that stops when the item is found or the array ends?

a)

A loop that will never end

b)

An efficient search that stops when the item is found or the array ends

c)

A range match

d)

A way to create parallel arrays

21.

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?

a)

Search an array for an exact value

b)

Sort an array

c)

Search an array for a range match

d)

Randomize array elements

22.

What is the error called when a subscript is used outside the acceptable range for an array?

a)

Out-of-bounds error

b)

Encapsulation error

c)

Ambiguity error

d)

Syntax error

23.

Accessing a memory location outside of the array by using an invalid subscript is what type of error?

a)

A compile-time error

b)

A syntax error

c)

A logical error

d)

A hardware error

24.

Which loop structure is especially convenient for processing every element in an array?

a)

while loop

b)

if-then-else

c)

for loop

d)

switch statement

25.

If an array is declared with 'num SIZE = 10', for a loop to process every element, the loop should run from 'dep = 0' to:

a)

SIZE

b)

SIZE - 1

c)

SIZE + 1

d)

1

26.

Given 'num someVals[3] = 25, 36, 47', what is the value of 'someVals[1]'?

a)

25

b)

36

c)

47

d)

Out of bounds

27.

If you use a variable as a subscript in an array, what must it be?

a)

A string

b)

Numeric with no decimal places

c)

A constant

d)

A boolean

28.

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)

A range match

b)

Searching an array for an exact match

c)

Incrementing a counter array

d)

Overloading the array

29.

If an array 'data' has 50 elements, what is the subscript of the last element?

a)

50

b)

49

c)

51

d)

data[last]

30.

To avoid 'magic numbers' in loops that process an array, what should you use?

a)

Hard-coded value (e.g., while x < 100)

b)

Named constant (e.g., while x < SIZE)

c)

Method

d)

Flag

31.

Which of the following is NOT a way constants are typically used with arrays?

a)

To hold the size of an array

b)

As the array's element values

c)

As an array subscript

d)

As a replacement for the array's name

32.

A method is a program module containing a series of statements that:

a)

Are executed in sequence to perform a specific task

b)

Are used only for array processing

c)

Must always return a value

d)

Can only be called once

33.

What is the primary purpose of a method in programming?

a)

Carry out a task

b)

Must return a numeric value

c)

Can only be called once

d)

Defines global variables

34.

What is the act of calling a method also known as?

a)

Invoking the method

b)

Declaring the method

c)

Encapsulating the method

d)

Hiding the method

35.

A program that calls a method is known as the method's:

a)

Parent

b)

Client

c)

Module

d)

Header

36.

Which of the following is NOT included in a method header?

a)

The return type

b)

The method name

c)

The parameter list

d)

The method's implementation (the statements)

37.

Where are the statements that carry out a method's tasks contained?

a)

Method header

b)

Method body

c)

Return statement

d)

Parameter list

38.

According to structured programming principles, a method should ideally have only one:

a)

Parameter

b)

Local variable

c)

Return statement, as the last statement

d)

if statement

39.

A data item declared within a method is _______ to that method.

a)

Global

b)

Local

c)

Encapsulated

d)

Ambiguous

40.

When a data item is known to all of a program's methods, it is a:

a)

Global data item

b)

Local data item

c)

Parameter

d)

Return value

41.

A variable is said to be 'in scope' when it:

a)

Is global

b)

Is out of bounds

c)

Exists and is usable

d)

Has been returned by a method

42.

When does a local variable 'go out of scope'?

a)

When the method in which it was declared ends

b)

When a global variable with the same name is declared

c)

After it is used once

d)

Never, it is permanent

43.

Which of the following is NOT a benefit of modularization?

a)

It provides abstraction, making the 'big picture' easier to see

b)

It allows multiple programmers to work on a problem

c)

It allows you to reuse your work

d)

It guarantees all variable names are unique without programmer effort

44.

What is the concept of completely containing data within a method, accessible only to that method, known as?

a)

Overloading

b)

Encapsulation or information hiding

c)

Passing by reference

d)

Ambiguity

45.

In a method call, the value passed in parentheses is the _______, while the variable in the method header that receives the value is the _______.

a)

argument; parameter

b)

parameter; argument

c)

local; global

d)

global; local

46.

When you pass a variable 'by value,' what is sent to the method?

a)

The variable's memory address

b)

A copy of the variable's value

c)

The variable's name

d)

Nothing

47.

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?

a)

20

b)

50

c)

70

d)

An error occurs

48.

When a method receives the memory address of the data passed to it, the data was:

a)

Passed by value

b)

Passed by reference

c)

A constant

d)

A local variable

49.

How is a single element of an array (e.g., myArray[3]) passed to a method?

a)

By reference

b)

By value

c)

It cannot be passed

d)

As a global variable

50.

How is an entire array passed to a method?

a)

By reference

b)

By value

c)

Each element is passed by value individually

d)

It is copied to a new local array

51.

If you pass an entire array to a method and the method changes the values of its elements, what happens to the original array?

a)

The original array is unchanged.

b)

The original array's elements are permanently changed.

c)

The method creates a copy of the array.

d)

An ambiguity error occurs.

52.

A method with a void return type:

a)

Returns nothing

b)

Returns a zero

c)

Returns a boolean value

d)

Accepts no parameters

53.

The data type specified before the method name in the header, such as num in num getHoursWorked(), is the:

a)

Method's type, which indicates its return type

b)

Parameter type

c)

Global type

d)

Overloaded type

54.

The value used in a return statement must match the:

a)

Data type of the first parameter

b)

Method's return type specified in the header

c)

Name of the method

d)

Number of arguments

55.

Writing multiple methods with the same name but different parameter lists is called:

a)

Encapsulation

b)

Ambiguity

c)

Method overloading

d)

Information hiding

56.

Which of the following is a valid overload for the method void printBill(num balance)?

a)

num printBill(num balance)

b)

void printBill(num total)

c)

void printBill(num balance, string message)

d)

void MyPrintBill(num balance)

57.

"Ambiguous methods" occur when:

a)

A method has too many parameters

b)

The compiler cannot determine which overloaded method to use

c)

A method calls itself

d)

A method returns a void type

58.

A program contains these two method headers. What is the result? num calc(num principal, num rate) string calc(num p, num r)

a)

This is valid method overloading.

b)

This is illegal; the compiler cannot tell them apart based on a call like calc(100, 0.05).

c)

This is encapsulation.

d)

This is passing by reference.

59.

A program contains these two method headers. What is the result? void checkValue(num a, string b) void checkValue(string b, num a)

a)

This is valid method overloading.

b)

This is illegal and ambiguous.

c)

This will cause a syntax error.

d)

This is an example of a void return.

60.

Prewritten methods provided by a programming language, such as mathematical functions, are known as:

a)

Built-in methods

b)

Local methods

c)

Ambiguous methods

d)

Overloaded methods

61.

In the method header string getFullName(string first, string last), the method's "type" is:

a)

string

b)

first

c)

last

d)

void

62.

Which of the following is not a benefit of using methods (modularization)?

a)

Provides abstraction

b)

Allows code reuse

c)

Makes a program run faster by using more memory

d)

Allows multiple programmers to work on a problem