Final-Quizes7,8,9,10 Flashcards

textbook chapters 6,7,10, & 14

1
Q

(7)An input validation loop is sometimes called an ERROR HANDLER(T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

(7)If a user is asked to enter the number of widgets he or she wants to buy and enters “two”, the program will automatically change the entry to an integer(T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

(7) If a user is asked to enter the number of widgets he or she wants to buy, the ISINTEGER function can be used to validate this input.(T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

(7)Programs should be designed to inspect all input before processing that input.(T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

(7)A priming read is needed when a pretest loop is executed.(T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

(7) A Boolean function can often be used to validate data(T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

(7) The most difficult input error to validate is an empty read.(T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

(7) Defensive programming is the practice of anticipating errors that an happen while a program is running and designing the program to catch and deal with those errors.(T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

(7) Checking for the accuracy of data, even when the user provides valid input, is part of input validation.(T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

(7) Checking that input data is reasonable is programmatically impossible.(T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

(7) Input validation is not needed if the program is well designed.(T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

(7) A programmer is not permitted to use library functions for input validation.(T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

(7) What do computer programmers say about the fact that computer can’t tell the difference between good and bad data?

A

Garbage in, Garbage out

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

(7-14) The purpose of _________ is to get the first input value for the validation of a loop.

A

The priming read

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

(7-15)Designing a program to avoid common errors is called ______________ programming.

A

defensive

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

(7)Input __________ is commonly done with a loop that iterates as long as an input variable contains bad data.

A

validation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

(7)A(n) ____________ is another term for input validation.

A

Error Trap

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

(7) The priming read is placed __________ the loop.

A

before

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

If the user, when asked for his/her date of birth, enters a date in the future, this error should be caught by a ________________ check.

A) date
B) time
C) reasonableness

A

C) reasonableness

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Accepting February 29 for input only in a leap year is a check that should be caught by a ____________ check.

A) date
B) time
C) reasonableness

A

A) date

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

(7)Which function could be used to validate an entry for a user’s chosen name that must be between 4 and 12 characters?

A

legnth

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

(7-22) Which function could be used to validate that the correct data type was input for an amount of money?

A)isReal
B)isString
C)Legnth

A

A)isReal

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

(7) which function could be used to simplify the process of string validation?

A)isReal
B)isString
C)toLower

A

C) toLower

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

(7) What would display if the following statements are coded and executed and the user enters 3 twice at the prompts?

Display “Enter your age:”
Input age
Do
Display “Impossible! Enter an age greater than 0:”
Input age
While age <=0
Display “Thank you”

A) Impossible! Enter an age greater than 0:

B) Thank you.
Impossible! Enter an age greater than 0:

C) Impossible! Enter an age greater than 0:
Thank you.

A

C) Impossible! Enter an age greater than 0:
Thank you.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

(7) What would display if the following statements are coded and executed and the user enters -3, at the first prompt, 0 at the next prompt, and 22 at the third prompt?

Display “Enter your age:”
Input age
While age <=0
Display “Impossible! Enter an age greater than 0:”
Input age
End While
Display “Thank you.”

A) Impossible! Enter an age greater than 0:
Impossible! Enter an age greater than 0:
Thank you.

B) Impossible! Enter an age greater than 0:
Impossible! Enter an age greater than 0:
Impossible! Enter an age greater than 0:

C) Thank you.

A

A) Impossible! Enter an age greater than 0:
Impossible! Enter an age greater than 0:
Thank you.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

(7-26) What is wrong with the following pseudocode that validates a user’s entry?

Display “Do you want to play again? Enter y or n.”
While toLower(choice) != “y” AND toLower (choice) != “n”
Display “Please answer y or n. Play again?”
Input choice
End While

A) There is no check for uppercase Y or N
B) There is no priming read
C) The Boolean expression should be an OR, not AND

A

B) There is no priming read

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

(6-15) Which function returns a string that is within another string?

A) append
B) contains
C) substring

A

C) substring

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

(6-1) Library functions are built into a programming language and can be called whenever they are needed(T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

The input column in an IPO chart describes the process that the function performs on input data.(T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

The input column in an IPO chart describes the process that the function performs on input data.(T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

Many programming languages let you assign an integer value to a real variable without causing an error(T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

(6) Random numbers are useful in simulation programs where the computer must randomly decide how an object will behave.(T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

(6) Random numbers are useful in simulation programs where the computer must randomly decide how an object will behave.(T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

(6-5) The function body follows the function header in a function definition.(T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

(6-5) The function body follows the function header in a function definition.(T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

(6)The TO INTEGER function accepts a real number as its argument and preserves any fractional part in the returned number(T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

(6) When a function finishes executing, it returns a value back to the part of the program that called it.(T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

(6)If the string variable name has the value “Anne Marie”, then the following statement would return 9:(T/F)

Set number = legnth(name)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

(6-9) If the string variable name has the value “Anne.Smith”, then the following statement would return annesmith.(T/F)

Set newName = toLower(name)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

(6) If the string variable name has the value “Anne.Smith”, then the following statement would return annesmith. (T/F)

Set newName = toLower(name)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

(6-10) If the integer variable number has the value 5, then the following statement would return 25 to result. (T/F)

Set result = sqrt(number)

A

False: sqrt(5) is not 25

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

Given an integer variable number, the only possible values for number that could result from the following statement are 1 and 2. (T/F)

Set number = random(0,2)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q

(6-12) The following pseudocode would display: Hello,friend.(T/F)

Declare String str1= “Hello,”
Declare String str2= “friend”
Set message = append(str1,str2)
Display Message

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

A function ___________ specifies the return data type, name of the function and the parameter variable(s).

A

header

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

(6)Which function accepts two strings as arguments and returns True if the second string is contained in the first string or FALSE if not?

A

contains

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

(6) Which function joins two strings?

A

concatenate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q

(6) What is the value of y after the following statement is coded and executed, given that x = 25?

Set y = sqrt(x)

A

5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q

What is the value of y after the following statement is coded and executed, given that x = 3?

Set y = pow(x,x)

A

27
bc (3^3)= 333= 9*3=27

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q

What is the value of r after the following statement is coded and executed?

Declare integer i = 12
Declare Real r
Set r = toReal(i)

A)12
B)1.2
C)12.0

A

C) 12.0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
50
Q

(6-20) What would display if the following pseudocode is coded and executed?

Declare String str1=”car”
Declare String str2 = “green”
Set message = append(str1,str2)
Display “You have a “,message

A) You have a greencar

B) you have a cargreen

A

B) you have a cargreen

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
51
Q

(6-20) What would display if the following pseudocode is coded and executed?

Declare String str1= “car”
Declare String str2= “green”
Set message = append(str1,str2)
Display “You have a”, message

A) You have a greencar
B) You have a green car
C) you have a cargreen

A

C) you have a cargreen
append means to squish together

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
52
Q

(6) A ___________ is a module that returns a value back to the part of the program that called it.

A

function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
53
Q

A function ___________ comprises one or more statements that are executed when the function is called

A

body

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
54
Q

What is the data type of the value returned by the random function?

A) Real
B) String
C) Integer

A

C) Integer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
55
Q

(6) The ___________ function does the same thing as using the mathematical ^ operator.

A

“pow” function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
56
Q

(6-25) Which of the following errors will occur when attempting to assign a real value to an integer variable?

A) conversion error
B) type mismatch error
C) assignment error

A

B) type mismatch error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
57
Q

(6) What would display if the following pseudocode was coded and executed?

Declare String user = “Joey”
If isInteger(user) Then
Set IntUser= stringTointeger(user)
Display IntUser
Else
Display “Not a valid number”

A

Not a valid number

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
58
Q

What would display if the following pseudocode was coded and executed?

Declare String grade = “93”
If isInteger(grade) Then
Set intGrade =stringToInteger(grade)
Display intGrade
Else
Display “Not a valid number”

A) 100
B) 93
C) Not a valid number

A

B) 93

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
59
Q

(6) What would display if the following pseudocode was coded and executed

Declare String user = “Martha and George”
Declare Integer number
Set number = legnth(user)
Display number

A) 17

B) 15

C) Martha and George

A

A) 17

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
60
Q

What would display if the following pseudocode was coded and executed?

Declare String user = “Martha and George”
Display substring (user, 1,3)

A

Art
bc count the characters starting from 0
the substring to be displayed are chars 1,2,3
A=1 R=2 T=3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
61
Q

(6-30) What would be the value of numS if the following pseudocode was coded and run?

Declare String prose = “She sells seashells at the seashore”
Declare Integer counter
Declare Integer numS = 0
For counter = 0 to legnth(prose)
If substring(prose, counter, counter) == “s” Then
Set numS = numS +1
End If
End For

A) 6
B) 8
C) 30

A

A) 6
bc prose has 5 chars + 1
is 6

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
62
Q

(8-1)Subscripts are used to identify specific elements in an array.(T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
63
Q

(8) Unlike variables, arrays need to be initialized separately from the declaration. (T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
64
Q

(8) Array bounds checking happens at runtime. (T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
65
Q

(8)The first step when calculating the average of all values in an array is to get the sum of all the values (T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
66
Q

(8-5) If an array, names consists of a list of usernames, then names[1] holds the value of the first username in the list.(T/F)

A

False
name[0] holds the first name in the list.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
67
Q

(8) Each element in a two dimensional array has two subscripts. (T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
68
Q

(8) To calculate the total of the values in an array, a loop is used with an accumulator variable.(T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
69
Q

An array, like a variable, can hold only one value.(T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
70
Q

(8)It is usually much easier to process a large number of items in an array than to process a large number of items that are stored in separate variables. (T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
71
Q

(8-10) The number of elements in an array is the value of the subscript of the last element in that array.(T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
72
Q

(8) One drawback to the sequential search is that it cannot be used with an array that contains string elements.(T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
73
Q

(8)The term “parallel array” is a synonym for a two-dimensional array.(T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
74
Q

(8) An individual element in an array is identified by its ____________.

A

subscript

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
75
Q

(8) A type of loop that exists in some programming languages specifically for stepping through an array and retreiving the value of each element is known as a ___________ loop.

A) Step
B) For Each
C) While Each

A

B) For Each

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
76
Q

(8-15)
____________ arrays are two or more arrays that hold related date where each element of one array has the same subscript as a corresponding element in the other arrays.

A

paralell arrays

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
77
Q

(8) Two-dimensional arrays can be thought as containing ____________.

A

rows and columns

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
78
Q

(8) Every element in an array is assigned a unique number known as a(n) __________.

A

subscript

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
79
Q

(8) What is the term used for the number inside the brackets of an array that specifies how many values the array can hold?

A

size declarator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
80
Q

(8)When working with arrays, most programming languages perform ____________ to ensure that programs don’t use invalid subscripts.

A

array bounds checking

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
81
Q

(8-20) What type of error occurs when a loop through an array iterates one time to few or one time too many?

A) runtime error
B) off-by-one error
C) validation error

A

B) off-by-one error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
82
Q

(8-21) How many subscripts do you need to access one element in a two-dimensional array?

A

Two

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
83
Q

(8) In the following declaration, what is the data type of the elements in the array?

Declare Integer numbers[SIZE]

A

Integer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
84
Q

(8-23) Which of the following statements is true about this array declaration??

Declare Integer numbers[5] = 123,456,789,321,654

A) This is an error; there should be 6 integers in the array
B) This is an array declaration and initialization
C) None of these statements are true

A

B) This is an array declaration and initialization

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
85
Q

Given the following statement, what is the subscript for the data value 92?

Declare Integer numbers[5] = 83,92,78,94,61

A

1 is the subscript

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
86
Q

(8-25) Which of the following array declarations would be best suited for storing prices of items sold in a store?

A) Declare Integer itemPrice[SIZE]

B) Declare Real itemPrice[SIZE]

C) Declare String itemPrice[SIZE]

A

B) Declare Real itemPrice[SIZE]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
87
Q

(8) What would display if following statements are coded and executed?

Declare Integer scores[3]= 76,94,83
Declare String names[3]= “Joe”,”Amy”,”Pat”
Display names[1]
Display “Your test score is: “
Display scores[2]

A) Joe Your test score is: 94

B) Amy your test score is: 94

C) Amy your test score is: 83

A

C) Amy your test score is: 83

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
88
Q

(8-27) Which is the correct way to pass an array named studentScores that holds 25 values to a function named getAverage and save the result to a variable named average?

A) Set average=getAverage (studentScores, 25)

B) Set getAverage = average(studentScores[25])

C) Set average = getAverage(studentScores)

A

A) Set average = getAverage(studentScores,25)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
89
Q

(6-1) Library functions are built into a programming language and can be called whenever they are needed(T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
89
Q

(6)The input column in an IPO chart describes the process that the function performs on input data.(T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
89
Q

(6) If the string variable name has the value “Anne Marie”, then the following statement would return 9:(T/F)

Set number = legnth(name)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
89
Q

(6) If the string variable name has the value “Anne.Smith”, then the following statement would return annesmith. (T/F)

Set newName = toLower(name)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
89
Q

(6-10) If the integer variable number has the value 5, then the following statement would return 25 to result. (T/F)

Set result = sqrt(number)

A

False: sqrt(5) is not 25

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
89
Q

(6-5) The function body follows the function header in a function definition.(T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
89
Q

(6) Random numbers are useful in simulation programs where the computer must randomly decide how an object will behave.(T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
89
Q

(6) What is the value of r after the following statement is coded and executed?

Declare integer i = 12
Declare Real r
Set r = toReal(i)

A)12
B)1.2
C)12.0

A

C) 12.0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
89
Q

(6)Many programming languages let you assign an integer value to a real variable without causing an error(T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
89
Q

Given an integer variable number, the only possible values for number that could result from the following statement are 1 and 2. (T/F)

Set number = random(0,2)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
89
Q

(6)Which function accepts two strings as arguments and returns True if the second string is contained in the first string or FALSE if not?

A

contains

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
89
Q

(6)The TO INTEGER function accepts a real number as its argument and preserves any fractional part in the returned number(T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
89
Q

(6)A function ___________ specifies the return data type, name of the function and the parameter variable(s).

A

header

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
89
Q

(6-15) Which function returns a string that is within another string?

A

substring

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
89
Q

(6) When a function finishes executing, it returns a value back to the part of the program that called it.(T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
89
Q

(6) Which function joins two strings?

A

concatenate

89
Q

A function ___________ comprises one or more statements that are executed when the function is called

A

body

89
Q

(6) What is the value of y after the following statement is coded and executed, given that x = 25?

Set y = sqrt(x)

A

5

89
Q

(6)What is the data type of the value returned by the random function?

A) Real
B) String
C) Integer

A

C) Integer

89
Q

(6) What is the value of y after the following statement is coded and executed, given that x = 3?

Set y = pow(x,x)

A

27
bc (3^3)= 333= 9*3=27

90
Q

(6) A ___________ is a module that returns a value back to the part of the program that called it.

A

function

90
Q

(6) The ___________ function does the same thing as using the mathematical ^ operator.

A

“pow” function

90
Q

(6-20) What would display if the following pseudocode is coded and executed?

Declare String str1= “car”
Declare String str2= “green”
Set message = append(str1,str2)
Display “You have a”, message

A) You have a greencar
B) You have a green car
C) you have a cargreen

A

C) you have a cargreen
append means to squish together

90
Q

(6-12) The following pseudocode would display: Hello,friend.(T/F)

Declare String str1= “Hello,”
Declare String str2= “friend”
Set message = append(str1,str2)
Display Message

A

True

90
Q

(6-30) What would be the value of numS if the following pseudocode was coded and run?

Declare String prose = “she sells seashells at the seashore”
Declare Integer counter
Declare Integer numS = 0
For counter = 0 to legnth(prose)
If substring(prose, counter, counter)== “s” Then
Set numS = numS +1
End If
End For

A) 6
B) 8
C) 30

A

A) 6
bc program is looped to run 6 times (0-legnth of prose which is 5 chars +1 from 0)
Therefore when it counts 6 s even if its not done the prose the program will end.

90
Q

(6-25) Which of the following errors will occur when attempting to assign a real value to an integer variable?

A) conversion error
B) type mismatch error
C) assignment error

A

B) type mismatch error

90
Q

(6) What would display if the following pseudocode was coded and executed?

Declare String user = “Martha and George”
Display substring (user, 1,3)

A

Art
bc count the characters starting from 0
the substring to be displayed are chars 1,2,3
A=1 R=2 T=3

90
Q

(6) What would display if the following pseudocode was coded and executed?

Declare String user = “Joey”
If isInteger(user) Then
Set IntUser= stringTointeger(user)
Display IntUser
Else
Display “Not a valid number”

A

Not a valid number

90
Q

(6) What would display if the following pseudocode was coded and executed?

Declare String grade = “93”
If isInteger(grade) Then
Set intGrade =stringToInteger(grade)
Display intGrade
Else
Display “Not a valid number”

A) 100
B) 93
C) Not a valid number

A

B) 93

91
Q

(6) What would display if the following pseudocode was coded and executed

Declare String user = “Martha and George”
Declare Integer number
Set number = legnth(user)
Display number

A) 17

B) 15

C) Martha and George

A

A) 17
counting the characters including the spaces in the “Martha and George” string adds to 17

91
Q

(8-28) Given the following array declaration, what value is stored in testScores[2][0]
Declare Integer testScores[3][3]=
66, 77, 88
98, 87, 76
65, 74, 89

A

65
DOWN 3 (2. but starts at 0)
OVER 0

92
Q

(9-1) In current gaming software, it is rare for data files to be needed(T/F)

A

False

93
Q

(9) The data saved in a file will remain there after the program ends but will be erased when the computer is turned off.(T/F)

A

False

94
Q

(9) In a text file, all data is stored as a series of characters.(T/F)

A

True

95
Q

(9) All types of files can be viewed correctly in a simple text editor. (T/F)

A

False

96
Q

(9-5) Sequential access files are easy to work with because you can immediately jump to any piece of data without reading all the data before it.(T/F)

A

False

97
Q

(9) The use of a buffer increases the system’s performance because writing data to memory is faster than writing data to a disk.(T/F)

A

True

98
Q

(9) When an input file is opened, the read position is initially set to the first item in the file.(T/F)

A

True

99
Q

(9) The term “output file” describes a file that data is read from. (T/F)

A

False

100
Q

(9) In a file a record is a complete set of data about an item and a field is an individual piece of data within a record.(T/F)

A

True

101
Q

(9-10) It is possible to manipulate data in a file directly without saving its contents to an array or anywhere else in a program.(T/F)

A

False

102
Q

(9) A file specification document describes the fields that are used in a file and is used to help programmers understand how the data is organized before they begin writing programs to manipulate that data.(T/F)

A

True

103
Q

(9) Control break logic is used when the programmer wants a program to terminate immediately.(T/F)

A

False

104
Q

(9) Programmers usually refer to the process of saving to a file as ____________ to a file.

A

writing

105
Q

(9) When a web page is visited, the browser may store a small file on the user’s computer. This file is known as a _____________.

A

cookie

106
Q

Opening a(n) ___________ file creates a file on disk and allows the program to write data to it

A

output

107
Q

(9) A character or set of characters that marks the end of a piece of data is known as a(n)

A

delimiter

108
Q

(9-17) In the ______________ step, the data is either written to the file or read from the file.

A

Processing

109
Q

(9-18) Which type of file cannot be viewed in a text editor such a Notepad?

A

Binary file

110
Q

(9) When using ___________ access, access to the data starts at the beginning of the file and the proceeds through all the records to the end of the file.

A

Sequential

111
Q

(9-20) When using ___________ access, the code can access any piece of data without reading all the data that came before it in the file.

A

Direct

112
Q

(9) In the pseudocode of the textbook, what does the following statement indicate?

Declare OutputFile itemsOrdered

A) itemsOrdered is the internal name used to work with the contents of a file

B) itemsOrdered is a file on disk and the program will read data from it

D) None of these statements are true

A

A) itemsOrdered is the internal name used to work with the contents of a file

113
Q

(9) In the pseudocode of the textbook, what does the following statement indicate?

Write itemsOrdered “widgets”

A) The file named itemsOrdered will be renamed widgets

B) The string “widgets” will be written to the file associated with itemsOrdered

C) itemsOrdered is a file on disk and the program will write the string “widgets” to it

A

B) The string “widgets” will be written to the file associated with itemsOrdered

114
Q

(9) In order to process the data in a file, first you must ____________ the file and then ____________ the data into memory.

A) Input, Write

B) Open, loop

C) Open, Read

A

C) Open, Read

115
Q

(9) The eof function _______________.

A) Accepts a file’s internal name as an argument and returns TRUE if the end of the file has been reached.

B) Accepts a file’s internal name as an argument and returns FALSE if the end of the file has been reached.

A

A) Accepts a file’s internal name as an argument and returns TRUE if the end of the file has been reached

116
Q

(9-25) Given the following pseudocode, what is the name of the file on the disk?

Declare String item
Declare Integer numOrdered
Declare InputFile stuffBought
Open stuffBought “inventory.dat”
Display “Your orders:”
While NOT eof(stuffBought)
Read stuffBought item, numOrdered
Display item, “: “, numOrdered
End While
Close stuffBought

A) stuffBought
B) inventory.dat

A

B) inventory.dat

117
Q

(9) Given the following pseudocode, what is the internal name used to work with the file on disk?

Declare String item
Declare Integer numOrdered
Declare InputFile stuffBought
Open stuffBought “inventory.dat”
Display “Your orders:”
While NOT eof(stuffBought)
Read stuffBought item, numOrdered
Display item, “: “, numOrdered
End While
Close stuffBought

A) stuffBought
B) inventory.dat

A

A) stuffBought

118
Q

(6-5) The function body follows the function header in a function definition.(T/F)

A

True

118
Q

(6)Many programming languages let you assign an integer value to a real variable without causing an error(T/F)

A

True

118
Q

(6) If the string variable name has the value “Anne.Smith”, then the following statement would return annesmith. (T/F)

Set newName = toLower(name)

A

False

118
Q

(6)The input column in an IPO chart describes the process that the function performs on input data.(T/F)

A

False

118
Q

(6)The TO INTEGER function accepts a real number as its argument and preserves any fractional part in the returned number(T/F)

A

False

118
Q

Given an integer variable number, the only possible values for number that could result from the following statement are 1 and 2. (T/F)

Set number = random(0,2)

A

False

118
Q

(6-12) The following pseudocode would display: Hello,friend.(T/F)

Declare String str1= “Hello,”
Declare String str2= “friend”
Set message = append(str1,str2)
Display Message

A

True

118
Q

(6) What is the value of y after the following statement is coded and executed, given that x = 3?

Set y = pow(x,x)

A

27
bc (3^3)= 333= 9*3=27

118
Q

(6-20) What would display if the following pseudocode is coded and executed?

Declare String str1= “car”
Declare String str2= “green”
Set message = append(str1,str2)
Display “You have a”, message

A) You have a greencar
B) You have a green car
C) you have a cargreen

A

C) you have a cargreen
append means to squish together

118
Q

(6) When a function finishes executing, it returns a value back to the part of the program that called it.(T/F)

A

True

118
Q

(6-10) If the integer variable number has the value 5, then the following statement would return 25 to result. (T/F)

Set result = sqrt(number)

A

False: sqrt(5) is not 25

118
Q

(6-1) Library functions are built into a programming language and can be called whenever they are needed(T/F)

A

True

118
Q

(6) A ___________ is a module that returns a value back to the part of the program that called it.

A

function

118
Q

(6) What would display if the following pseudocode was coded and executed

Declare String user = “Martha and George”
Declare Integer number
Set number = legnth(user)
Display number

A) 17

B) 15

C) Martha and George

A

A) 17
counting the characters including the spaces in the “Martha and George” string adds to 17

118
Q

(6) Random numbers are useful in simulation programs where the computer must randomly decide how an object will behave.(T/F)

A

True

119
Q

(6)What is the data type of the value returned by the random function?

A) Real
B) String
C) Integer

A

C) Integer

119
Q

(6) If the string variable name has the value “Anne Marie”, then the following statement would return 9:(T/F)

Set number = legnth(name)

A

False

119
Q

(6-15) Which function returns a string that is within another string?

A

substring

119
Q

(6)A function ___________ specifies the return data type, name of the function and the parameter variable(s).

A

header

119
Q

(6) What would display if the following pseudocode was coded and executed?

Declare String user = “Martha and George”
Display substring (user, 1,3)

A

Art
bc count the characters starting from 0
the substring to be displayed are chars 1,2,3
A=1 R=2 T=3

119
Q

(6) What would display if the following pseudocode was coded and executed?

Declare String grade = “93”
If isInteger(grade) Then
Set intGrade =stringToInteger(grade)
Display intGrade
Else
Display “Not a valid number”

A) 100
B) 93
C) Not a valid number

A

B) 93

119
Q

(6)Which function accepts two strings as arguments and returns True if the second string is contained in the first string or FALSE if not?

A

contains

119
Q

(6) Which function joins two strings?

A

concatenate

120
Q

A function ___________ comprises one or more statements that are executed when the function is called

A

body

120
Q

(6) What is the value of r after the following statement is coded and executed?

Declare integer i = 12
Declare Real r
Set r = toReal(i)

A)12
B)1.2
C)12.0

A

C) 12.0

120
Q

(6) What is the value of y after the following statement is coded and executed, given that x = 25?

Set y = sqrt(x)

A

5

120
Q

(6) The ___________ function does the same thing as using the mathematical ^ operator.

A

“pow” function

121
Q

(6-25) Which of the following errors will occur when attempting to assign a real value to an integer variable?

A) conversion error
B) type mismatch error
C) assignment error

A

B) type mismatch error

121
Q

(6) What would display if the following pseudocode was coded and executed?

Declare String user = “Joey”
If isInteger(user) Then
Set IntUser= stringTointeger(user)
Display IntUser
Else
Display “Not a valid number”

A

Not a valid number

121
Q

(6-30) What would be the value of numS if the following pseudocode was coded and run?

Declare String prose = “she sells seashells at the seashore”
Declare Integer counter
Declare Integer numS = 0
For counter = 0 to legnth(prose)
If substring(prose, counter, counter)== “s” Then
Set numS = numS +1
End If
End For

A) 6
B) 8
C) 30

A

A) 6
bc program is looped to run 6 times (0-legnth of prose which is 5 chars +1 from 0)
Therefore when it counts 6 s even if its not done the prose the program will end.

121
Q

(9-27) Which of the following expressions is equivalent to the pseudocode shown here?

NOT eof(myStuff)

A) eof(myStuff) == False
B) eof(myStuff) == True
C) not eof == myStuff

A

A) eof(myStuff) == False

122
Q

(6-1) Library functions are built into a programming language and can be called whenever they are needed(T/F)

A

True

122
Q

(6) Random numbers are useful in simulation programs where the computer must randomly decide how an object will behave.(T/F)

A

True

123
Q

(6)The input column in an IPO chart describes the process that the function performs on input data.(T/F)

A

False

123
Q

(6)Many programming languages let you assign an integer value to a real variable without causing an error(T/F)

A

True

123
Q

(6) When a function finishes executing, it returns a value back to the part of the program that called it.(T/F)

A

True

123
Q

(6-5) The function body follows the function header in a function definition.(T/F)

A

True

123
Q

(6)A function ___________ specifies the return data type, name of the function and the parameter variable(s).

A

header

123
Q

(6-10) If the integer variable number has the value 5, then the following statement would return 25 to result. (T/F)

Set result = sqrt(number)

A

False: sqrt(5) is not 25

123
Q

Given an integer variable number, the only possible values for number that could result from the following statement are 1 and 2. (T/F)

Set number = random(0,2)

A

False

123
Q

(6) If the string variable name has the value “Anne Marie”, then the following statement would return 9:(T/F)

Set number = legnth(name)

A

False

123
Q

(6)The TO INTEGER function accepts a real number as its argument and preserves any fractional part in the returned number(T/F)

A

False

123
Q

(6) What is the value of y after the following statement is coded and executed, given that x = 3?

Set y = pow(x,x)

A

27
bc (3^3)= 333= 9*3=27

123
Q

(6) If the string variable name has the value “Anne.Smith”, then the following statement would return annesmith. (T/F)

Set newName = toLower(name)

A

False

123
Q

(6) A ___________ is a module that returns a value back to the part of the program that called it.

A

function

123
Q

A function ___________ comprises one or more statements that are executed when the function is called

A

body

123
Q

(6) Which function joins two strings?

A

concatenate

123
Q

(6)Which function accepts two strings as arguments and returns True if the second string is contained in the first string or FALSE if not?

A

contains

123
Q

(6-20) What would display if the following pseudocode is coded and executed?

Declare String str1= “car”
Declare String str2= “green”
Set message = append(str1,str2)
Display “You have a”, message

A) You have a greencar
B) You have a green car
C) you have a cargreen

A

C) you have a cargreen
append means to squish together

123
Q

(6)What is the data type of the value returned by the random function?

A) Real
B) String
C) Integer

A

C) Integer

124
Q

(6) What is the value of r after the following statement is coded and executed?

Declare integer i = 12
Declare Real r
Set r = toReal(i)

A)12
B)1.2
C)12.0

A

C) 12.0

124
Q

(6-15) Which function returns a string that is within another string?

A

substring

124
Q

(6) What is the value of y after the following statement is coded and executed, given that x = 25?

Set y = sqrt(x)

A

5

124
Q

(6-12) The following pseudocode would display: Hello,friend.(T/F)

Declare String str1= “Hello,”
Declare String str2= “friend”
Set message = append(str1,str2)
Display Message

A

True

124
Q

(6) What would display if the following pseudocode was coded and executed?

Declare String user = “Martha and George”
Display substring (user, 1,3)

A

Art
bc count the characters starting from 0
the substring to be displayed are chars 1,2,3
A=1 R=2 T=3

124
Q

(6) What would display if the following pseudocode was coded and executed?

Declare String grade = “93”
If isInteger(grade) Then
Set intGrade =stringToInteger(grade)
Display intGrade
Else
Display “Not a valid number”

A) 100
B) 93
C) Not a valid number

A

B) 93

124
Q

(6) What would display if the following pseudocode was coded and executed?

Declare String user = “Joey”
If isInteger(user) Then
Set IntUser= stringTointeger(user)
Display IntUser
Else
Display “Not a valid number”

A

Not a valid number

124
Q

(6) The ___________ function does the same thing as using the mathematical ^ operator.

A

“pow” function

124
Q

(6) What would display if the following pseudocode was coded and executed

Declare String user = “Martha and George”
Declare Integer number
Set number = legnth(user)
Display number

A) 17

B) 15

C) Martha and George

A

A) 17
counting the characters including the spaces in the “Martha and George” string adds to 17

124
Q

(6-25) Which of the following errors will occur when attempting to assign a real value to an integer variable?

A) conversion error
B) type mismatch error
C) assignment error

A

B) type mismatch error

125
Q

(6-30) What would be the value of numS if the following pseudocode was coded and run?

Declare String prose = “she sells seashells at the seashore”
Declare Integer counter
Declare Integer numS = 0
For counter = 0 to legnth(prose)
If substring(prose, counter, counter)== “s” Then
Set numS = numS +1
End If
End For

A) 6
B) 8
C) 30

A

A) 6
bc program is looped to run 6 times (0-legnth of prose which is 5 chars +1 from 0)
Therefore when it counts 6 s even if its not done the prose the program will end.

125
Q

(10-1) The act of declaring a class variable does not actually create an object in memory. (T/F)

A

True

126
Q

(10-2) If a constructor is not written when the class is compiled, then a constructor is automatically provided and is known as the ‘default constructor’. (T/F)

A

True

127
Q

(10) Entities do not have direct acess to the object’s private methods.(T/F)

A

True

128
Q

(10) In an inheritance relationship, the superclass inherits members from the subclass.(T/F)

A

False

129
Q

(10-5) There are primarily three methods of programming in use today: procedural recursive, and object oriented.(T/F)

A

False

130
Q

(10) UML (Unified Modeling Language) is another name for a flowchart that uses classes.(T/F)

A

False

131
Q

(10) A constructor is a member of a class that holds data.(T/F)

A

False

132
Q

(10) ____________ programming is centered on the procedures of actions that take place in a program.

A

procedural

133
Q

(10) ___________ programming encapsulates data and functions in an object.

A

object-oriented programming

134
Q

(10-10) A(n) __________ entity contains both data and procedures.

A

object

135
Q

(10) The variables, arrays, or other data structures that are stored in an object are known as the object’s _____________.

A

fields

136
Q

(10) The procedures that an object performs are known as the object’s _____________.

A

methods

137
Q

(10) In the pseudocode of the textbook, a class ____________ starts with the word Class, followed by the name of the class.

A

definition

138
Q

(10) The fields and methods that belong in a class are known as the class’s _____________.

A

members

139
Q

(10-15) In a class definition, if the word Private appears before a field declaration, Private is known as a(n) _________________.

A

access specifer

140
Q

(10-16) Mutator methods are sometimes called ___________.

A

Setters

141
Q

(10) Another name for accessor methods is _____________.

A

Getters

142
Q

(10) The ability to create methods with the same name that are in different classes is known as ______________.

A

polymorphism

143
Q

(10) A(n) __________ is a standard way to draw diagrams that describe object-oriented systems.

A

UML diagram

144
Q

(10-20) In a UML diagram the ____________ character placed in front of a field or method name, indicates that it is Public.

A) -
B) =
C) +

A

C) +

145
Q

The ____________ method is automatically called when an object is created.

A

constructor

146
Q

(6-1) Library functions are built into a programming language and can be called whenever they are needed(T/F)

A

True

146
Q

(6) If the string variable name has the value “Anne Marie”, then the following statement would return 9:(T/F)

Set number = legnth(name)

A

False

146
Q

(6)Many programming languages let you assign an integer value to a real variable without causing an error(T/F)

A

True

146
Q

(6)The TO INTEGER function accepts a real number as its argument and preserves any fractional part in the returned number(T/F)

A

False

146
Q

(6) When a function finishes executing, it returns a value back to the part of the program that called it.(T/F)

A

True

146
Q

Given an integer variable number, the only possible values for number that could result from the following statement are 1 and 2. (T/F)

Set number = random(0,2)

A

False

146
Q

(6-5) The function body follows the function header in a function definition.(T/F)

A

True

146
Q

(6)The input column in an IPO chart describes the process that the function performs on input data.(T/F)

A

False

146
Q

(6) What is the value of y after the following statement is coded and executed, given that x = 25?

Set y = sqrt(x)

A

5

146
Q

(6-12) The following pseudocode would display: Hello,friend.(T/F)

Declare String str1= “Hello,”
Declare String str2= “friend”
Set message = append(str1,str2)
Display Message

A

True

146
Q

(6) What would display if the following pseudocode was coded and executed

Declare String user = “Martha and George”
Declare Integer number
Set number = legnth(user)
Display number

A) 17

B) 15

C) Martha and George

A

A) 17
counting the characters including the spaces in the “Martha and George” string adds to 17

146
Q

(6)A function ___________ specifies the return data type, name of the function and the parameter variable(s).

A

header

146
Q

(6) What is the value of y after the following statement is coded and executed, given that x = 3?

Set y = pow(x,x)

A

27
bc (3^3)= 333= 9*3=27

146
Q

(6) What is the value of r after the following statement is coded and executed?

Declare integer i = 12
Declare Real r
Set r = toReal(i)

A)12
B)1.2
C)12.0

A

C) 12.0

146
Q

(6-20) What would display if the following pseudocode is coded and executed?

Declare String str1= “car”
Declare String str2= “green”
Set message = append(str1,str2)
Display “You have a”, message

A) You have a greencar
B) You have a green car
C) you have a cargreen

A

C) you have a cargreen
append means to squish together

146
Q

(6)What is the data type of the value returned by the random function?

A) Real
B) String
C) Integer

A

C) Integer

146
Q

(6) What would display if the following pseudocode was coded and executed?

Declare String user = “Martha and George”
Display substring (user, 1,3)

A

Art
bc count the characters starting from 0
the substring to be displayed are chars 1,2,3
A=1 R=2 T=3

146
Q

(6)Which function accepts two strings as arguments and returns True if the second string is contained in the first string or FALSE if not?

A

contains

146
Q

(6) Which function joins two strings?

A

concatenate

147
Q

(6-15) Which function returns a string that is within another string?

A

substring

147
Q

(6) What would display if the following pseudocode was coded and executed?

Declare String user = “Joey”
If isInteger(user) Then
Set IntUser= stringTointeger(user)
Display IntUser
Else
Display “Not a valid number”

A

Not a valid number

147
Q

(6) The ___________ function does the same thing as using the mathematical ^ operator.

A

“pow” function

147
Q

(6) If the string variable name has the value “Anne.Smith”, then the following statement would return annesmith. (T/F)

Set newName = toLower(name)

A

False

147
Q

(6) A ___________ is a module that returns a value back to the part of the program that called it.

A

function

147
Q

A function ___________ comprises one or more statements that are executed when the function is called

A

body

148
Q

(6-25) Which of the following errors will occur when attempting to assign a real value to an integer variable?

A) conversion error
B) type mismatch error
C) assignment error

A

B) type mismatch error

148
Q

(6-30) What would be the value of numS if the following pseudocode was coded and run?

Declare String prose = “she sells seashells at the seashore”
Declare Integer counter
Declare Integer numS = 0
For counter = 0 to legnth(prose)
If substring(prose, counter, counter)== “s” Then
Set numS = numS +1
End If
End For

A) 6
B) 8
C) 30

A

A) 6
bc program is looped to run 6 times (0-legnth of prose which is 5 chars +1 from 0)
Therefore when it counts 6 s even if its not done the prose the program will end.

149
Q

(6) Random numbers are useful in simulation programs where the computer must randomly decide how an object will behave.(T/F)

A

True

149
Q

(6-10) If the integer variable number has the value 5, then the following statement would return 25 to result. (T/F)

Set result = sqrt(number)

A

False: sqrt(5) is not 25

149
Q

(6) What would display if the following pseudocode was coded and executed?

Declare String grade = “93”
If isInteger(grade) Then
Set intGrade =stringToInteger(grade)
Display intGrade
Else
Display “Not a valid number”

A) 100
B) 93
C) Not a valid number

A

B) 93

149
Q

(10-22) Given a class named Animals and a class variable named ducky which will reference an Animals object, which the correct way, using the textbook’s pseudocode, to create an Animal’s object?

A) Set ducky = New Animals( )
B) Set ducky = Animals( )
C) Set Animals = New ducky( )

A

A) Set ducky = New Animals( )