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
- The Single data type is used to store words or phrases.
- The Project Explorer window shows the properties of an object.
- The Text property is the most important property of a text
box.
- SetFocus is considered to be an event.
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.
- There are no syntax errors in the statement: txtDisplay.Text
= Str("55")
- There are no syntax errors in the statement: txtDisplay.Text
= strFirstName & "Doe"
- There are no syntax errors in the statement: intFinal = StrComp("Al",
"Bill")
- There are no syntax errors in the statement: strName = Trim("_Hello_")
(where the underscores represent blank spaces)
- There are no syntax errors in the statement: lblProduct.Caption
= "Wyomissing"
- There are no syntax errors in the statement: intCounter =
intCounter + 1
- There are no syntax errors in the statement: sngAmount =
InputBox("Enter a value: ")
- There are no syntax errors in the statement: For x = 1 To
100 Step 0.5
- There are no syntax errors in the statement: Text1.Text =
"Hello"
- There are no syntax errors in the statement: txtText2.Visible
= False
- There are no syntax errors in the statement: intNumber =
15 Mod 2
- There are no syntax errors in the statement: Dim intScore
As WholeNumber
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"
- Val(strNumber)
- Val("3.22" & "5.4")
- intSum4 Mod intSum5 + 10
- intTotalE – intTotalC + intTotalD
- Len("Hello") + intSum5
- Len("Sum4")
- StrComp("Fit", "Fat", 1)
- StrComp("a", "abc", 1)
- StrComp("Snow", "Weather", 0)
- StrComp(Len(strDept), applesauce", 1)
- strNumber & Str(intNum3)
- Str(intSum3 + intTotalC)
- intSum2 - intSum3 + intTotalD
- Trim(strCity)
Fill-in-the-Blank – Neatly PRINT the
best, most precise answer
- RAM stands for _____ .
- Eight _____ make up one byte.
- True is most often represented by the binary digit, _____
.
- Text boxes should be named with the prefix of ______ .
- An error in a program is often called a _____ by programmers.
- To convert a _____ into a value, you use the Val function.
- For a And b to be True, the values of a and b must both be
_____ .
- The null string is also referred to as the _____ string
- The And keyword is considered to be a _____ operator in VB.
- The _____ property of a label determines what the user will
see on the form.
- A For/Next loop is a ______ loop.
- The _____ function is used to create a message box.
- An Option Explicit statement should always be used in the
general _____ section of a module or form.
- 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.
- Write a VB statement that would declare the sngSum
as a Single variable.
- Write a Do/While loop that will make the computer beep 5
times. Use intLoop as a loop variable.
- 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.
- 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.
- 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.
- 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.
- In a paragraph, explain what a test plan is and how it is
used in the programming process.