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
(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) Impossible! Enter an age greater than 0: Impossible! Enter an age greater than 0: Thank you.
26
(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
B) There is no priming read
27
(6-15) Which function returns a string that is within another string? A) append B) contains C) substring
C) substring
28
(6-1) Library functions are built into a programming language and can be called whenever they are needed(T/F)
True
29
The input column in an IPO chart describes the process that the function performs on input data.(T/F)
False
30
The input column in an IPO chart describes the process that the function performs on input data.(T/F)
False
31
Many programming languages let you assign an integer value to a real variable without causing an error(T/F)
True
32
(6) Random numbers are useful in simulation programs where the computer must randomly decide how an object will behave.(T/F)
True
33
(6) Random numbers are useful in simulation programs where the computer must randomly decide how an object will behave.(T/F)
True
34
(6-5) The function body follows the function header in a function definition.(T/F)
True
35
(6-5) The function body follows the function header in a function definition.(T/F)
True
36
(6)The TO INTEGER function accepts a real number as its argument and preserves any fractional part in the returned number(T/F)
False
37
(6) When a function finishes executing, it returns a value back to the part of the program that called it.(T/F)
True
38
(6)If the string variable name has the value "Anne Marie", then the following statement would return 9:(T/F) Set number = legnth(name)
False
39
(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)
False
40
(6) If the string variable name has the value "Anne.Smith", then the following statement would return annesmith. (T/F) Set newName = toLower(name)
False
41
(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)
False: sqrt(5) is not 25
42
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)
False
43
(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
True
44
A function ___________ specifies the return data type, name of the function and the parameter variable(s).
header
45
(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?
contains
46
(6) Which function joins two strings?
concatenate
47
(6) What is the value of y after the following statement is coded and executed, given that x = 25? Set y = sqrt(x)
5
48
What is the value of y after the following statement is coded and executed, given that x = 3? Set y = pow(x,x)
27 bc (3^3)= 3*3*3= 9*3=27
49
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
C) 12.0
50
(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
B) you have a cargreen
51
(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
C) you have a cargreen append means to squish together
52
(6) A ___________ is a module that returns a value back to the part of the program that called it.
function
53
A function ___________ comprises one or more statements that are executed when the function is called
body
54
What is the data type of the value returned by the random function? A) Real B) String C) Integer
C) Integer
55
(6) The ___________ function does the same thing as using the mathematical ^ operator.
"pow" function
56
(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
B) type mismatch error
57
(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"
Not a valid number
58
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
B) 93
59
(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) 17
60
What would display if the following pseudocode was coded and executed? Declare String user = “Martha and George” Display substring (user, 1,3)
Art bc count the characters starting from 0 the substring to be displayed are chars 1,2,3 A=1 R=2 T=3
61
(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) 6 bc prose has 5 chars + 1 is 6
62
(8-1)Subscripts are used to identify specific elements in an array.(T/F)
True
63
(8) Unlike variables, arrays need to be initialized separately from the declaration. (T/F)
False
64
(8) Array bounds checking happens at runtime. (T/F)
True
65
(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)
True
66
(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)
False name[0] holds the first name in the list.
67
(8) Each element in a two dimensional array has two subscripts. (T/F)
True
68
(8) To calculate the total of the values in an array, a loop is used with an accumulator variable.(T/F)
True
69
An array, like a variable, can hold only one value.(T/F)
False
70
(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)
True
71
(8-10) The number of elements in an array is the value of the subscript of the last element in that array.(T/F)
False
72
(8) One drawback to the sequential search is that it cannot be used with an array that contains string elements.(T/F)
False
73
(8)The term "parallel array" is a synonym for a two-dimensional array.(T/F)
False
74
(8) An individual element in an array is identified by its ____________.
subscript
75
(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
B) For Each
76
(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.
paralell arrays
77
(8) Two-dimensional arrays can be thought as containing ____________.
rows and columns
78
(8) Every element in an array is assigned a unique number known as a(n) __________.
subscript
79
(8) What is the term used for the number inside the brackets of an array that specifies how many values the array can hold?
size declarator
80
(8)When working with arrays, most programming languages perform ____________ to ensure that programs don't use invalid subscripts.
array bounds checking
81
(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
B) off-by-one error
82
(8-21) How many subscripts do you need to access one element in a two-dimensional array?
Two
83
(8) In the following declaration, what is the data type of the elements in the array? Declare Integer numbers[SIZE]
Integer
84
(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
B) This is an array declaration and initialization
85
Given the following statement, what is the subscript for the data value 92? Declare Integer numbers[5] = 83,92,78,94,61
1 is the subscript
86
(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]
B) Declare Real itemPrice[SIZE]
87
(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
C) Amy your test score is: 83
88
(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) Set average = getAverage(studentScores,25)
89
(6-1) Library functions are built into a programming language and can be called whenever they are needed(T/F)
True
89
(6)The input column in an IPO chart describes the process that the function performs on input data.(T/F)
False
89
(6) If the string variable name has the value "Anne Marie", then the following statement would return 9:(T/F) Set number = legnth(name)
False
89
(6) If the string variable name has the value "Anne.Smith", then the following statement would return annesmith. (T/F) Set newName = toLower(name)
False
89
(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)
False: sqrt(5) is not 25
89
(6-5) The function body follows the function header in a function definition.(T/F)
True
89
(6) Random numbers are useful in simulation programs where the computer must randomly decide how an object will behave.(T/F)
True
89
(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
C) 12.0
89
(6)Many programming languages let you assign an integer value to a real variable without causing an error(T/F)
True
89
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)
False
89
(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?
contains
89
(6)The TO INTEGER function accepts a real number as its argument and preserves any fractional part in the returned number(T/F)
False
89
(6)A function ___________ specifies the return data type, name of the function and the parameter variable(s).
header
89
(6-15) Which function returns a string that is within another string?
substring
89
(6) When a function finishes executing, it returns a value back to the part of the program that called it.(T/F)
True
89
(6) Which function joins two strings?
concatenate
89
A function ___________ comprises one or more statements that are executed when the function is called
body
89
(6) What is the value of y after the following statement is coded and executed, given that x = 25? Set y = sqrt(x)
5
89
(6)What is the data type of the value returned by the random function? A) Real B) String C) Integer
C) Integer
89
(6) What is the value of y after the following statement is coded and executed, given that x = 3? Set y = pow(x,x)
27 bc (3^3)= 3*3*3= 9*3=27
90
(6) A ___________ is a module that returns a value back to the part of the program that called it.
function
90
(6) The ___________ function does the same thing as using the mathematical ^ operator.
"pow" function
90
(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
C) you have a cargreen append means to squish together
90
(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
True
90
(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) 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
(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
B) type mismatch error
90
(6) What would display if the following pseudocode was coded and executed? Declare String user = “Martha and George” Display substring (user, 1,3)
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
(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"
Not a valid number
90
(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
B) 93
91
(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) 17 counting the characters including the spaces in the "Martha and George" string adds to 17
91
(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
65 DOWN 3 (2. but starts at 0) OVER 0
92
(9-1) In current gaming software, it is rare for data files to be needed(T/F)
False
93
(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)
False
94
(9) In a text file, all data is stored as a series of characters.(T/F)
True
95
(9) All types of files can be viewed correctly in a simple text editor. (T/F)
False
96
(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)
False
97
(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)
True
98
(9) When an input file is opened, the read position is initially set to the first item in the file.(T/F)
True
99
(9) The term "output file" describes a file that data is read from. (T/F)
False
100
(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)
True
101
(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)
False
102
(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)
True
103
(9) Control break logic is used when the programmer wants a program to terminate immediately.(T/F)
False
104
(9) Programmers usually refer to the process of saving to a file as ____________ to a file.
writing
105
(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 _____________.
cookie
106
Opening a(n) ___________ file creates a file on disk and allows the program to write data to it
output
107
(9) A character or set of characters that marks the end of a piece of data is known as a(n)
delimiter
108
(9-17) In the ______________ step, the data is either written to the file or read from the file.
Processing
109
(9-18) Which type of file cannot be viewed in a text editor such a Notepad?
Binary file
110
(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.
Sequential
111
(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.
Direct
112
(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) itemsOrdered is the internal name used to work with the contents of a file
113
(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
B) The string “widgets” will be written to the file associated with itemsOrdered
114
(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
C) Open, Read
115
(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) Accepts a file’s internal name as an argument and returns TRUE if the end of the file has been reached
116
(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
B) inventory.dat
117
(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) stuffBought
118
(6-5) The function body follows the function header in a function definition.(T/F)
True
118
(6)Many programming languages let you assign an integer value to a real variable without causing an error(T/F)
True
118
(6) If the string variable name has the value "Anne.Smith", then the following statement would return annesmith. (T/F) Set newName = toLower(name)
False
118
(6)The input column in an IPO chart describes the process that the function performs on input data.(T/F)
False
118
(6)The TO INTEGER function accepts a real number as its argument and preserves any fractional part in the returned number(T/F)
False
118
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)
False
118
(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
True
118
(6) What is the value of y after the following statement is coded and executed, given that x = 3? Set y = pow(x,x)
27 bc (3^3)= 3*3*3= 9*3=27
118
(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
C) you have a cargreen append means to squish together
118
(6) When a function finishes executing, it returns a value back to the part of the program that called it.(T/F)
True
118
(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)
False: sqrt(5) is not 25
118
(6-1) Library functions are built into a programming language and can be called whenever they are needed(T/F)
True
118
(6) A ___________ is a module that returns a value back to the part of the program that called it.
function
118
(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) 17 counting the characters including the spaces in the "Martha and George" string adds to 17
118
(6) Random numbers are useful in simulation programs where the computer must randomly decide how an object will behave.(T/F)
True
119
(6)What is the data type of the value returned by the random function? A) Real B) String C) Integer
C) Integer
119
(6) If the string variable name has the value "Anne Marie", then the following statement would return 9:(T/F) Set number = legnth(name)
False
119
(6-15) Which function returns a string that is within another string?
substring
119
(6)A function ___________ specifies the return data type, name of the function and the parameter variable(s).
header
119
(6) What would display if the following pseudocode was coded and executed? Declare String user = “Martha and George” Display substring (user, 1,3)
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
(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
B) 93
119
(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?
contains
119
(6) Which function joins two strings?
concatenate
120
A function ___________ comprises one or more statements that are executed when the function is called
body
120
(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
C) 12.0
120
(6) What is the value of y after the following statement is coded and executed, given that x = 25? Set y = sqrt(x)
5
120
(6) The ___________ function does the same thing as using the mathematical ^ operator.
"pow" function
121
(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
B) type mismatch error
121
(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"
Not a valid number
121
(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) 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
(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) eof(myStuff) == False
122
(6-1) Library functions are built into a programming language and can be called whenever they are needed(T/F)
True
122
(6) Random numbers are useful in simulation programs where the computer must randomly decide how an object will behave.(T/F)
True
123
(6)The input column in an IPO chart describes the process that the function performs on input data.(T/F)
False
123
(6)Many programming languages let you assign an integer value to a real variable without causing an error(T/F)
True
123
(6) When a function finishes executing, it returns a value back to the part of the program that called it.(T/F)
True
123
(6-5) The function body follows the function header in a function definition.(T/F)
True
123
(6)A function ___________ specifies the return data type, name of the function and the parameter variable(s).
header
123
(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)
False: sqrt(5) is not 25
123
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)
False
123
(6) If the string variable name has the value "Anne Marie", then the following statement would return 9:(T/F) Set number = legnth(name)
False
123
(6)The TO INTEGER function accepts a real number as its argument and preserves any fractional part in the returned number(T/F)
False
123
(6) What is the value of y after the following statement is coded and executed, given that x = 3? Set y = pow(x,x)
27 bc (3^3)= 3*3*3= 9*3=27
123
(6) If the string variable name has the value "Anne.Smith", then the following statement would return annesmith. (T/F) Set newName = toLower(name)
False
123
(6) A ___________ is a module that returns a value back to the part of the program that called it.
function
123
A function ___________ comprises one or more statements that are executed when the function is called
body
123
(6) Which function joins two strings?
concatenate
123
(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?
contains
123
(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
C) you have a cargreen append means to squish together
123
(6)What is the data type of the value returned by the random function? A) Real B) String C) Integer
C) Integer
124
(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
C) 12.0
124
(6-15) Which function returns a string that is within another string?
substring
124
(6) What is the value of y after the following statement is coded and executed, given that x = 25? Set y = sqrt(x)
5
124
(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
True
124
(6) What would display if the following pseudocode was coded and executed? Declare String user = “Martha and George” Display substring (user, 1,3)
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
(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
B) 93
124
(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"
Not a valid number
124
(6) The ___________ function does the same thing as using the mathematical ^ operator.
"pow" function
124
(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) 17 counting the characters including the spaces in the "Martha and George" string adds to 17
124
(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
B) type mismatch error
125
(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) 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
(10-1) The act of declaring a class variable does not actually create an object in memory. (T/F)
True
126
(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)
True
127
(10) Entities do not have direct acess to the object's private methods.(T/F)
True
128
(10) In an inheritance relationship, the superclass inherits members from the subclass.(T/F)
False
129
(10-5) There are primarily three methods of programming in use today: procedural recursive, and object oriented.(T/F)
False
130
(10) UML (Unified Modeling Language) is another name for a flowchart that uses classes.(T/F)
False
131
(10) A constructor is a member of a class that holds data.(T/F)
False
132
(10) ____________ programming is centered on the procedures of actions that take place in a program.
procedural
133
(10) ___________ programming encapsulates data and functions in an object.
object-oriented programming
134
(10-10) A(n) __________ entity contains both data and procedures.
object
135
(10) The variables, arrays, or other data structures that are stored in an object are known as the object's _____________.
fields
136
(10) The procedures that an object performs are known as the object's _____________.
methods
137
(10) In the pseudocode of the textbook, a class ____________ starts with the word Class, followed by the name of the class.
definition
138
(10) The fields and methods that belong in a class are known as the class's _____________.
members
139
(10-15) In a class definition, if the word Private appears before a field declaration, Private is known as a(n) _________________.
access specifer
140
(10-16) Mutator methods are sometimes called ___________.
Setters
141
(10) Another name for accessor methods is _____________.
Getters
142
(10) The ability to create methods with the same name that are in different classes is known as ______________.
polymorphism
143
(10) A(n) __________ is a standard way to draw diagrams that describe object-oriented systems.
UML diagram
144
(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) +
C) +
145
The ____________ method is automatically called when an object is created.
constructor
146
(6-1) Library functions are built into a programming language and can be called whenever they are needed(T/F)
True
146
(6) If the string variable name has the value "Anne Marie", then the following statement would return 9:(T/F) Set number = legnth(name)
False
146
(6)Many programming languages let you assign an integer value to a real variable without causing an error(T/F)
True
146
(6)The TO INTEGER function accepts a real number as its argument and preserves any fractional part in the returned number(T/F)
False
146
(6) When a function finishes executing, it returns a value back to the part of the program that called it.(T/F)
True
146
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)
False
146
(6-5) The function body follows the function header in a function definition.(T/F)
True
146
(6)The input column in an IPO chart describes the process that the function performs on input data.(T/F)
False
146
(6) What is the value of y after the following statement is coded and executed, given that x = 25? Set y = sqrt(x)
5
146
(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
True
146
(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) 17 counting the characters including the spaces in the "Martha and George" string adds to 17
146
(6)A function ___________ specifies the return data type, name of the function and the parameter variable(s).
header
146
(6) What is the value of y after the following statement is coded and executed, given that x = 3? Set y = pow(x,x)
27 bc (3^3)= 3*3*3= 9*3=27
146
(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
C) 12.0
146
(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
C) you have a cargreen append means to squish together
146
(6)What is the data type of the value returned by the random function? A) Real B) String C) Integer
C) Integer
146
(6) What would display if the following pseudocode was coded and executed? Declare String user = “Martha and George” Display substring (user, 1,3)
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
(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?
contains
146
(6) Which function joins two strings?
concatenate
147
(6-15) Which function returns a string that is within another string?
substring
147
(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"
Not a valid number
147
(6) The ___________ function does the same thing as using the mathematical ^ operator.
"pow" function
147
(6) If the string variable name has the value "Anne.Smith", then the following statement would return annesmith. (T/F) Set newName = toLower(name)
False
147
(6) A ___________ is a module that returns a value back to the part of the program that called it.
function
147
A function ___________ comprises one or more statements that are executed when the function is called
body
148
(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
B) type mismatch error
148
(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) 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
(6) Random numbers are useful in simulation programs where the computer must randomly decide how an object will behave.(T/F)
True
149
(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)
False: sqrt(5) is not 25
149
(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
B) 93
149
(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) Set ducky = New Animals( )