CSIS 208 Quiz 4

CSIS 208 Quiz 4 Liberty University

  1. 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)
  2. Assuming the following statement, what is the For…Next loop’s counter variable?
    For yr As Integer = 1 To 5
  3. If the counter variable of a For…Next loop will assume values that are not whole numbers, then the variable must not be of type Integer. (T/F)
  4. The ReDim statement causes an array to lose its current contents unless the word ReDim is followed by the keyword
  5. The step value of a For…Next loop can be given by a numeric literal, variable, or expression. (T/F)
  6. 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
  7. Arrays are said to be ordered only if the values are in ascending order. (T/F)
  8. 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
    Items.Add(query.Count)
    lstBox.Items.Add(query.Average)
  9. What is displayed in the message box by the following code?
    Dim message As String
    Dim teamNames() As String = {“Packers”, “Jets”, “Seahawks”}
    ReDim Preserve teamNames(1)
    message = teamNames(1)
    Show(message)
  10. The ReDim and Preserve keywords can be used with two-dimensional arrays. (T/F)
  11. In the line of code
    Function Sum(scores() As Integer) As Integer
    the pair of parentheses that follows scores can be removed. (T/F)
  12. The number of items in ListBox1 is ListBox1.Items.Count. (T/F)
  13. A structure can contain members that are simple variables only; members cannot be arrays. (T/F)
  14. Do…Loop Until block is always executed at least once. (T/F)
  15. 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
    Items.Add(state)
    Next
    Function ContainsE(word As String) As Boolean
    If word.IndexOf(“E”) <> -1 Or word.IndexOf(“e”) <> -1 Then
    Return True
    Else
    Return False
    End If
    End Function

  16. 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
    Items.Add(query.Count)
    lstBox.Items.Add(query.Average)
  17. In a For…Next loop, the initial value should be greater than or equal to the terminating value if a negative step is used and the body of the loop is to be executed at least once. (T/F)
  18. 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
    Items.Add(query.First)
    lstBox.Items.Add(query.Max)
  19. Which of the following are valid for an initial or terminating value of a For…Next loop?
  20. What numbers are displayed in the list box by the following program segment?
    Dim numbers() As Integer = {4, 7, 9, 3, 1, 7, 7}
    Dim query = From number in numbers
    Where number > 6
    Select number
    Distinct
    Items.Add(query.Count)
    lstBox.Items.Add(query.Average)
$2.99
Buy Answer Key

has been added to your cart!

have been added to your cart!

Files Included - Liberty University
  1. CSIS 208 Quiz 4