Basic Programming Practice Midterm Exam

Answers to this practice exam that were provided by former students are provided here. They may be incorrect for this updated version of the practice exam. If you notice any errors, discuss them with Mr. Minich.

What to bring:    #2 pencils with good erasers

True/False

  1. The Single data type is used to store words or phrases.
  2. The Project Explorer window shows the properties of an object.
  3. The Text property is the most important property of a text box.
  4. SetFocus is considered to be an event.
  5. For the following True/False questions, assume all necessary variables have been declared appropriately. Note that a syntax error is an error that prevents the line from executing.

  6. There are no syntax errors in the statement: txtDisplay.Text = Str("55")
  7. There are no syntax errors in the statement: txtDisplay.Text = strFirstName & "Doe"
  8. There are no syntax errors in the statement: intFinal = StrComp("Al", "Bill")
  9. There are no syntax errors in the statement: strName = Trim("_Hello_") (where the underscores represent blank spaces)
  10. There are no syntax errors in the statement: lblProduct.Caption = "Wyomissing"
  11. There are no syntax errors in the statement: intCounter = intCounter + 1
  12. There are no syntax errors in the statement: sngAmount = InputBox("Enter a value: ")
  13. There are no syntax errors in the statement: For x = 1 To 100 Step 0.5
  14. There are no syntax errors in the statement: Text1.Text = "Hello"
  15. There are no syntax errors in the statement: txtText2.Visible = False
  16. There are no syntax errors in the statement: intNumber = 15 Mod 2
  17. There are no syntax errors in the statement: Dim intScore As WholeNumber
  18. Determine the Output – Neatly PRINT your answers.

    Assume that the following variables have been properly declared and contain the following values. Evaluate the expressions in this section based on these variables. Each problem is independent and separate from the others, therefore you should not change the values of any variables. Blank spaces are indicated by underscore characters ( _ ). If an expression would cause a syntax error then write the answer "Error". If the final answer is a string, make sure that you surround the answer with double quotes. Use the underscore character ( _ ) to indicated blank spaces in your answers.

    intSum = 20
    strName = "Flintstone"
    intTotalA = -101
    intAmount = 44.1
    intSum2 = -5
    strCity = "Newark"
    intTotalB = 0
    sngAmountB = 0.72
    intSum3 = 10
    strState = "TEXAS"
    intTotalC = 200
    sngAmountC = 43.111
    intSum4 = 45654
    strDept = "Home_Ec _"
    intTotalD = -2
    sngAmountD = 3.898
    intSum5 = 8
    strWeather = "SleEt"
    intTotalE = 6
    strNumber = "4"

  19. Val(strNumber)
  20. Val("3.22" & "5.4")
  21. intSum4 Mod intSum5 + 10
  22. intTotalE – intTotalC + intTotalD
  23. Len("Hello") + intSum5
  24. Len("Sum4")
  25. StrComp("Fit", "Fat", 1)
  26. StrComp("a", "abc", 1)
  27. StrComp("Snow", "Weather", 0)
  28. StrComp(Len(strDept), applesauce", 1)
  29. strNumber & Str(intNum3)
  30. Str(intSum3 + intTotalC)
  31. intSum2 - intSum3 + intTotalD
  32. Trim(strCity)
  33. Fill-in-the-Blank – Neatly PRINT the best, most precise answer

  34. RAM stands for _____ .
  35. Eight _____ make up one byte.
  36. True is most often represented by the binary digit, _____ .
  37. Text boxes should be named with the prefix of ______ .
  38. An error in a program is often called a _____ by programmers.
  39. To convert a _____ into a value, you use the Val function.
  40. For a And b to be True, the values of a and b must both be _____ .
  41. The null string is also referred to as the _____ string
  42. The And keyword is considered to be a _____ operator in VB.
  43. The _____ property of a label determines what the user will see on the form.
  44. A For/Next loop is a ______ loop.
  45. The _____ function is used to create a message box.
  46. An Option Explicit statement should always be used in the general _____ section of a module or form.
  47. A bottom-checking indeterminant loop guarantees that at least _____ iteration(s) will occur.

Short Answer/Essays – Answer the following as completely as possible. Make sure that you use complete sentences and proper grammar. Be as descriptive and as explanatory as possible and support your answers with examples if possible or where necessary. When asked to write VB statements, PRINT your answer and be sure to use proper capitalization, indentation, and spacing.

  1. Write a VB statement that would declare the sngSum as a Single variable.
  2. Write a Do/While loop that will make the computer beep 5 times. Use intLoop as a loop variable.
  3. Write an If/Then/Else statement that assigns the value of 30 to the variable intTeamScore if intPoints is greater than or equal to 20. Otherwise, the value of 10 should be stored in intTeamScore.
  4. Write a VB statement that would ask the user to enter an amount of a purchase using an input box and that assigns that value to the variable sngUserInput. The input prompt "Enter your purchase amount: " should be displayed in the input box.
  5. Write a Select Case statement that displays the word "Good" in the caption of the label lblOutput if intNum is equal to 50. If intNum is equal to 40, the word "Okay" should be displayed in the caption of lblOutput. Otherwise, the message "Not good" should be displayed there.
  6. Write a complete program that displays the message "Hello" in the caption of the label lblOutput when the user clicks the command button named cmdClick.
  7. In a paragraph, explain what a test plan is and how it is used in the programming process.