“Computer Science 230 – Fall 2004
09/30/04 Mid Term Test # 1 Test Form A
Name:
Instructions:
Answer ALL questions on the answer sheet provided.
Hand in TEST, Answer Sheet, and Help Sheet, each with your name on it.
Remember to put the letter of your test form on your answer sheet.
Please ask any clarifying questions you have (come up).
Completion (3 points each)
4. A(n) __________ is a piece of information passed to a method.
True/False (2 points each)
6. The computer will not print an error message when a logic error occurs.
7. A variable can appear on both sides of the assignment operator in the same assignment statement.
Multiple Choice (3 points each)
A) It is desirable to put the most important information at the bottom of the form
B) Controls should NOT be aligned, due to the excess space needed for that approach
C) The flow of the form should be top to bottom and/or left to right
D) Use as many colors as possible to aid in distinguishing one control from another
E) None of the above
A) Specifying Option Explicit On and Option Strict On will result in having to write extra code to accomplish the same thing
B) Option Explicit On and Option Strict On, if specified, are specified near the top of the module (code file)
C) Specifying Option Explicit On and Option Strict On will help you by causing the IDE to catch some of your silly mistakes for you
D) All of the above
E) None of the above
Valid/Invalid – Variables (5 points total)
A) 2ndPlace
B) FirstPlace
C) third place
D) winnerGame3
E) Cost$
Valid/Invalid (4 points each)
For each, tell whether valid or invalid. If invalid, tell why!
Generally they are taken out of context, we assume that valid context surrounds them (e.g. inside a program, variables declared, given values if necessary, etc)
if hours <= 40 Xor salary > 100000 then
pay = basePay
else
pay = basePay + overtime
end if
Select case stdNum
Case 1 to 1000
Msgbox(“freshman”)
Case 1000 to 1999
Msgbox(“sophomore”)
Case 2000 to 2999
Msgbox(“junior”)
Case else
Msgbox(“senior”)
end select
const wet as integer = 5;
wet = wet + 1;
Dim z as integer
Dim x as integer
z = 5
x = 6
z + 4 = x
Short Answer (points as shown)
(4 points)
(6 points)
Doing and Understanding: (5 points each)
Dim wacky as integer
Dim weird as integer
Dim psycho as integer
Dim worriesome as integer
wacky = 12
weird = 34
psycho = 45
worriesome = 33
if (wacky >weird) then
msgbox(“wacky”)
elseif (psycho > worrisome) then
msgbox(“psycho”)
elseif (weird > worrisome) then
msgbox(“weird”)
elseif (wacky > psycho) then
msgbox(“help!”)
else
msgbox(“talk”)
end if
msgbox(“last”)
Dim a as integer
a = 8;
if (a > 5) || (a < 0) then
msgbox("ifthen");
else
msgbox("else")
end if
Dim x as integer
x = 5
if (x > 3) then
if (x < 10) then
x = x + 1
else
x = x + 2
end if
else
x = x + 3
end if
msgbox( x.toString(“n0”)
Dim color as integer
color = 3;
select case color
case 1
msgbox ("red ")
case 2
msgbox ("red ")
case 3
msgbox ("blue")
case 4:
msgbox ("purple")
Case else
msgbox ("gray")
End select
Writing Code (points as shown)
(10 points)
(15 points)