Introduction to Programming Using Visual Basic 10th Edition Schneider Test Bank pdf download
Introduction to Programming Using Visual Basic 10th Edition Schneider Test Bank pdf download
https://testbankfan.com/product/introduction-to-programming-
using-visual-basic-10th-edition-schneider-test-bank/
https://testbankfan.com/product/introduction-to-programming-
using-visual-basic-10th-edition-schneider-solutions-manual/
https://testbankfan.com/product/introduction-to-programming-
using-visual-basic-2012-9th-edition-schneider-test-bank/
https://testbankfan.com/product/introduction-to-programming-
using-visual-basic-2012-9th-edition-schneider-solutions-manual/
https://testbankfan.com/product/introduction-to-programming-
using-python-1st-edition-schneider-test-bank/
Introduction to Programming Using Python 1st Edition
Schneider Solutions Manual
https://testbankfan.com/product/introduction-to-programming-
using-python-1st-edition-schneider-solutions-manual/
https://testbankfan.com/product/programming-in-visual-
basic-2010-1st-edition-bradley-test-bank/
https://testbankfan.com/product/programming-with-microsoft-
visual-basic-2012-6th-edition-zak-test-bank/
https://testbankfan.com/product/programming-with-microsoft-
visual-basic-2017-8th-edition-zak-test-bank/
https://testbankfan.com/product/programming-with-microsoft-
visual-basic-2015-7th-edition-zak-solutions-manual/
Chapter 7 Arrays
1. After the following Dim statement is executed, how many elements will the array myVar
have?
Dim myVar(7) As Double
(A) 0
(B) 1
(C) 8
(D) 9
C
4. In the statement
Dim scores(30) As Double
the Count method is used to carry out which of the following tasks?
(A) determine the largest value for each of the elements
(B) determine the largest subscript in the array
(C) determine the smallest value for each of the elements
(D) declare a new array with the name Count
B
8. The ReDim statement causes an array to lose its current contents unless the word ReDim is
followed by the keyword
(A) CInt
(B) MyBase
(C) Preserve
(D) Add
C
9. Like other variables, array variables can be declared and assigned initial values at the same
time. (T/F)
T
10. After an array has been declared, its type (but not its size) can be changed with a ReDim
statement. (T/F)
F
11. If you use the ReDim statement to make an array smaller than it was, data in the eliminated
elements can be retrieved by using the Preserve keyword. (T/F)
F
13. What will be the size of the array stones after the following two lines of code are executed?
Dim stones() As String = {"Watts", "Jagger", "Wood", "Richards"}
ReDim Preserve stones(10)
11
is used to declare an array where each element has the value 10. (T/F)
F
17. What two names are displayed in the list box when the button is clicked on?
Dim krispies(2) as String
19. Either a For...Next loop or a For Each loop can be used to display every other value from an
array in a list box. (T/F)
F
20. An array can contain both numeric and string values. (T/F)
F
21. A Function procedure can return a number, but cannot return an array of numbers. (T/F)
F
22. What names are displayed in the list box when the button is clicked on?
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim names() As String = IO.File.ReadAllLines("Data.txt")
lstBox.Items.Clear()
For i As Integer = (names.Count - 1) To 0 Step -2
lstBox.Items.Add(names(i))
Next
End Sub
Assume the five lines of the file Data.txt contain the following entries: Bach, Borodin,
Brahms, Beethoven, Britain.
(A) Bach, Brahms, and Britain
(B) Britain, Beethoven, Brahms, Borodin, and Bach
(C) Bach, Borodin, Brahms, Beethoven, and Britain
(D) Britain, Brahms, and Bach
D
24. What numbers are displayed in the list box when the button is clicked on?
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim file As String = "Beatles.txt"
Dim fabFour() As String = FillArray(file)
lstBox.Items.Add(Array.IndexOf(fabFour, "Ringo")
lstBox.Items.Add(fabFour.Count - 1)
End Sub
Assume the four lines of the file Beatles.txt contain the following entries: John, Paul, Ringo,
George.
(A) 3 and 3
(B) 3 and 4
(C) 2 and 3
(D) 2 and 4
C
26. What numbers are displayed in the list box by the following program segment?
Dim numbers As String = "1492,1776,1945"
Dim temp() As String = numbers.Split(","c)
Dim nums(2) As Integer
For i As Integer = 0 to 2
nums(i) = CInt(temp(i))
Next
lstBox.Items.Add(nums(1))
lstBox.Items.Add(nums.First)
(A) 10000
(B) 11110
(C) 1110
(D) 0
B
30. Given the Dim statement below, which set of statements will initialize all elements of
myArray to 100?
Dim myArray(100) As Double
34. Consider the following Dim and assignment statements for myArray(). The assignment
statement will cause a "Subscript out of range" error. (T/F)
Dim myArray(50) As Double
myArray(34) = 51
F
35. Unless otherwise specified, Visual Basic assigns the value 0 to each element of a numeric
array when it is declared with a Dim statement. (T/F)
T
39. Which of the tasks is the Join function used to carry out in the following statement?
Dim line As String
line = Join(strArrData, ",")
(A) Join concatenates the values of all elements of the array strArrData, and adds a comma
delimiter between successive values.
(B) Join concatenates the values of all elements of line, and adds a comma to the end of the
line.
(C) Join parses or separates out all items of text that are delimited by a comma in
strArrData.
(D) Join parses or separates out all items of text that are delimited by a comma in line.
A
2. What numbers are displayed in the list box by the following program segment?
Dim numbers() As Integer = {4, 7, 9, 3, 1}
Dim query = From number in numbers
Where number > 6
Select number
lstBox.Items.Add(query.Count)
lstBox.Items.Add(query.Average)
(A) 5 and 12
(B) 2 and 12
(C) 2 and 8
(D) 5 and 8
C
3. What numbers are displayed in the list box by the following program segment?
Dim numbers() As Integer = {4, 7, 9, 3, 1, 9, 7}
Dim query = From number in numbers
Where number > 6
Select number
lstBox.Items.Add(query.Count)
lstBox.Items.Add(query.Average)
(A) 7 and 12
(B) 4 and 8
(C) 2 and 12
(D) 7 and 8
B
5. What states are displayed in the list box by the following program segment?
Dim states() As String = {"Colorado", "New Mexico", "Arizona", "Utah"}
Dim query = From state in states
Where ContainsE(state)
Select state
For Each state in query
lstBox.Items.Add(state)
Next
(A) Utah
(B) COLORADO, NEW MEXICO, ARIZONA, UTAH
(C) UTAH
(D) No states
C
7. What numbers are displayed in the list box by the following program segment?
Dim states() As String = {"Colorado", "New Mexico", "Arizona", "Utah"}
Dim query = From state in states
Where state.EndsWith("o")
Select state.Length
For Each number in query
lstBox.Items.Add(number)
Next
(A) 8 and 10
(B) 8, 10, 7, 4
(C) 8
(D) 29
A
8. What names are displayed in the list box by the following program segment?
Dim tonightShow() As String = {"Allen", "Parr", "Carson", "Leno",
"O'Brien", "Leno"}
Dim query = From host in tonightShow
Where host.Length = 4
Select host
Distinct
For Each host in query
lstBox.Items.Add(host)
Next
10. What years are displayed in the list box by the following program segment?
Dim years() As Integer = {1492, 1776, 1840, 1929, 1945, 2005}
Dim query = From year in years
Where Is20thCentury(year)
Select year
For Each yr in query
lstBox.Items.Add(yr)
Next
12. What words are displayed in the list box by the following program segment?
Dim deadlySins() As String = {"pride", "greed", "anger", "envy",
"lust", "gluttony", "sloth"}
Dim query = From sin in deadlySins
Order By sin Ascending
Where sin.StartsWith("g")
Select sin
lstBox.Items.Add(query.First)
lstBox.Items.Add(query.Max)
13. What words are displayed in the list box by the following program segment?
Dim deadlySins() As String = {"pride", "greed", "anger", "envy",
"lust", "gluttony", "sloth"}
Dim query = From sin in deadlySins
Order By sin.Length Descending
Select sin.ToUpper
lstBox.Items.Add(query.First)
lstBox.Items.Add(query.Min)
15. What colleges are displayed in the list box by the following program segment?
Dim ivies() As String = {"Harvard", "Princeton", "Yale", "Dartmouth",
"Brown", "Columbia", "Univ. of PA", "Cornell"}
Dim query = From college in ivies
Where college.Length <= 9
Order By college.Length Descending, college Descending
Select college
lstBox.Items.Add(query.Last)
lstBox.Items.Add(query.Min)
16. What colleges are displayed in the list box by the following program segment?
Dim ivies() As String = {"Harvard", "Princeton", "Yale", "Dartmouth",
"Brown", "Columbia", "Univ. of PA", "Cornell"}
Dim query = From college in ivies
Where college.Length <= 9
Order By college.Length Descending, college Ascending
Select college
lstBox.Items.Add(query.First)
lstBox.Items.Add(query.Max)
18. What numbers are displayed in the list box by the following program segment?
Dim numbers() As Integer = {5, 79, 8, 33, 27}
Dim query = From number in numbers
Let formattedNum = number.ToString("N0")
Order By formattedNum Ascending
Select formattedNum
lstBox.DataSource = query.ToList
lstBox.SelectedIndex = Nothing
22. Arrays are said to be ordered only if the values are in ascending order. (T/F)
F
24. Searching successive elements of an ordered list beginning with the first element is known
as a binary search. (T/F)
F
1. Consider the following structure definition. Which Dim statement would correctly declare
an array of this structure for elements having subscripts from 0 through 30?
Structure carType
Dim yr As Integer
Dim make As String
Dim model As String
End Structure
(A) You cannot have an array of structures.
(B) Dim carType(30)
(C) Dim car(30) As carType
(D) Dim carType(30) As car
C
2. Consider the following Structure definition and declaration. Which assignment statement
would correctly record that player number 13 had three home runs so far this season?
Structure playerType
Dim fullname As String
Dim team As String
Dim position As String
Dim homerun As Double
Dim average As Double
Dim rbi As Double
End Structure
(A) player(13) = 3
(B) player(13).homerun(3)
(C) playerType(13).homerun = 3
(D) player(13).homerun = 3
(E) None of the above
D
5. The members of a structure must all be of the same data type. (T/F)
F
8. A structure can contain members that are simple variables only; members cannot be arrays.
(T/F)
F
10. Suppose a structure and an array are created with the code
Structure Nation
Dim name As String
Dim continent As String
Dim population As Double 'in millions
Dim area As Double 'in square miles
End Structure
Structure Nation
Dim name As String
Dim continent As String
Dim population As Double 'in millions
Dim area As Double 'in square miles
End Structure
Structure Nation
Dim name As String
Dim continent As String
Dim population As Double 'in millions
Dim area As Double 'in square miles
End Structure
Structure Nation
Dim name As String
Dim continent As String
Dim population As Double 'in millions
Dim area As Double 'in square miles
End Structure
(A) Three columns, with headers country, population, and area. The grid will display the
countries in Europe (along with their populations and areas) whose names begin with
the letter S. The countries will be displayed capitalized in alphabetical order and their
populations and areas will be formatted with commas as thousands separators.
(B) Four columns, with headers countryUC, continent, pop, and area. The grid will display
the countries in Europe (along with their continents, populations and areas) whose
names begin with the letter S. The countries will be displayed capitalized in alphabetical
order and their populations and areas will be formatted with commas as thousands
separators.
(C) Three columns, with headers countryUC, pop, and area. The grid will display the
countries in Europe (along with their populations and areas) whose names begin with
the letter S. The countries will be displayed capitalized in alphabetical order and their
populations and areas will be formatted with commas as thousands separators.
(D) Three columns, with headers countryUC, pop, and area. The grid will display the
countries in Europe (along with their populations and areas) whose names begin with
the letter S. The countries will be displayed capitalized in reverse alphabetical order and
their populations and areas will be formatted with commas as thousands separators.
C
myArray
num = myArray(3,4) 0 1 2 3 4
0 0 1 2 3 4
1 5 6 7 8 9
2 10 11 12 13 14
3 15 16 17 18 19
4 20 21 22 23 24
(A) 19
(B) 4
(C) 24
(D) 0
(E) None of the above
A
2. Assume the array nums has been filled as shown. What is the output of the following
program segment?
nums
0 1 2 3
s = 0 |------------------------
For k As Integer = 0 To 2 0 | 2 3 4 5
s += nums(k, k + 1) |
Next 1 | 6 5 4 3
lstBox.Items.Add(s) |
2 | 2 3 4 5
|
3 | 6 5 4 3
(A) 64
(B) 12
(C) 13
(D) 25
(E) None of the above
B
4. Which of the following types of variables is capable of holding the information contained in
a table that has four rows and four columns?
(A) one-dimensional arrays
(B) simple variables
(C) single-subscripted variables
(D) double-subscripted variables
D
5. Which of the following types of variables can only hold a single item of data?
(A) two-dimensional arrays
(B) simple variables
(C) single-subscripted variables
(D) double-subscripted variables
B
8. Arrays that are capable of holding the contents of a table with several rows and columns, are
known as two-dimensional arrays or double subscripted variables. (T/F)
T
declares a two-dimensional array that can store a table containing 7 rows and 8 columns of
numeric data. (T/F)
F
11. A two-dimensional array can be declared and initialized at the same time. (T/F)
T
12. If the two-dimensional array nums has three rows and six columns, then the value of
nums.GetUpperBound(0) is 3 and the value of nums.GetUpperBound(1) is 6. (T/F)
F
14. The ReDim and Preserve keywords can be used with two-dimensional arrays. (T/F)
T
16. ReDim statements cannot be used to change a one-dimensional array into a two-dimensional
array. (T/F)
T
17. ReDim statements can be used to change a one-dimensional array into a three-dimensional
array. (T/F)
F
18. Given the following statements, the first subscript in the second statement references a
column. (T/F)
Dim myArray(15, 20) As Double
myArray(5, 10) = 0
F
21. Write code using a For...Next loop to fill a 5-by-5 matrix so that the two diagonals have
asterisks (*) in them as shown.
0 1 2 3 4
0 * *
1 * *
2 *
3 * *
4 * *
Ans: For i As Integer = 0 to 4
matrix(i, i) = "*"
matrix(i, 4 - i) = "*"
Next
Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.