Unit 4 and 5 Review Flashcards Preview

Computer Programming > Unit 4 and 5 Review > Flashcards

Flashcards in Unit 4 and 5 Review Deck (39):
1

Jamie keyed "Interger" instead of "Integer". What type of error resulted?
A. run-time error
B. dynamic error
C. syntax error
D. logic error

C. syntax error

2

Which is an example of a try...catch?
A. Try
intNum = Convert.ToInt32(txtNum. Text)
Catch ex As Exception
MessageBox.Show("Enter a numeric value")
End Try
B. Try
intNum = Convert.ToInt32(txtNum.Text)
Catch ex As Exception
MessageBox.Show("Enter a numeric value")
End
C. Try
intNum = Convert. ToInt32(txtNum.Text)
Catch Exception
MessageBox.Show("Enter a numeric value")
End Try
D. Try Exception
intNum = Convert.ToInt32(txtNum.Text)
Catch ex As Exception
MessageBox.Show("Enter a numeric value")
End

A. Try
intNum = Convert.ToInt32(txtNum. Text)
Catch ex As Exception
MessageBox.Show("Enter a numeric value")
End Try

3

A Boolean variable can contain:

A. True and false.
B. On and off.
C. Positive and negative.
D. Long and short.

A. True and false.

4

Susan declares a variable within an If statement. What is the scope of this variable?
A. Local
B. Procedural
C. Global
D. Non-Local

B. Procedural

5

Which data type is appropriate to store the number five (5)?
A. Char
B. Integer
C. String
D. Boolean

B. Integer

6

In what type of loop are the conditions evaluated before the instructions are processed?
A. Pretest
B. Infinite
C. Finite
D. Posttest

A. Pretest

7

Given the following code segment, what is the value of intNumber that displays in the Label?
Dim intCount, intNumber As Integerint
Count = 0
intNumber = 0
Do
intNumber = intNumber + 2
intCount = intCount + 1
Loop Until intCount > 3
lblAnswer.Text = intNumber
A. 6
B. 8
C. 4
D. 2
Response Feedback: 5.05

B. 8

8

Which button would be clicked before START in order to run an application using the menu bar?
A. Build
B. Project
C. Debug
D. View

C. Debug

9

Grades are based on the scale below. Using this scale, which condition(s) would be used to identify students who made a "D" or an "F"?
A 93-100
B 85-92
C 78-84
D 70-77
F 0-69
A. dblScore >= 0 And dblScore = 80
C. dblScore 0
D. dblScore = 78

A. dblScore >= 0 And dblScore

10

Which data type is used to declare a variable that will store the value 0.113?
A. String
B. Double
C. Char
D. Boolean

B. Double

11

Variable names:
A. Must begin with a letter
B. Can contain spaces
C. Must contain a digit
D. Can be a keyword

A. Must begin with a letter

12

Which statement correctly assigns the value 5 to the variable intNum?
A. intNum (5)
B. 5 = intNum
C. intNum = 5
D. intNum 5

C. intNum = 5

13

North Carolina allows a teenager to have a learner's permit if they are 15 and have had driver's education training. Consider the intAge and blnHasHadDrivEd variables. Which of the following If conditions would allow alearner's permit?
A. intAge = 15 Or blnHasHadDrivEd = True
B. intAge > 14 Or blnHasHadDrivEd = True
C. intAge = 15 And blnHasHadDrivEd = True
D. intAge

C. intAge = 15 And blnHasHadDrivEd = True

14

Sara thought her program would calculate grade point averages, but the program listed the highest grade instead.What type of error is this?
A. dynamic error
B. logic error
C. run-time error
D. syntax error

B. logic error

15

Alice wrote a program that executed but did not produce the expected output. What is the BEST method for Aliceto find the error?
A. Hover over the variables in the code to change the output.
B. Add try catch.
C. Debug the program.
D. Add break-points and step through the code while watching the variable output.

D. Add break-points and step through the code while watching the variable output.

16

Which statement correctly displays a messagebox with the message "Programming is awesome!"?
A. MessageBox.Show("Programming is awesome!")
B. MessageBox.Text = "Programming is awesome!"
C. MessageBox.Show = ("Programming is awesome!")
D. MessageBox.Show = "Programming is awesome!"

A. MessageBox.Show("Programming is awesome!")

17

Given the following statements:
Dim intExperience As Integer = 10
If intExperience > 5 Then
lblMessage.Text="Sufficient Experience"
Else
lblMessage.Text="Inexperienced"
End If
What is displayed when the statements execute?

A. Sufficient Experience
B. Inexperienced
C. Sufficient Experience on one line and inexperience on the other
D. Nothing would be displayed

A. Sufficient Experience

18

Examine the code below. What value is stored in intResult after the loop executes?
Dim intCount As Integer
Dim intResult As Integer
For intCount= 0 to 11 Step 2
intResult = intResult + 1
Next
A. 10
B. 12
C. 11
D. 6

D. 6

19

Typically, accumulators and counters are initialized to this value
A. nothing
B. 0
C. 2
D. 1

B. 0

20

In the following code, how many times does the program count through the loop structure?
For intCounter as integer = 1 To 5
A. 0
B. 1
C. 5
D. The loop will not start

C. 5

21

Which type of error produces undesired or unexpected results?
A. Run-time error
B. Syntax error
C. Logic error
D. Dynamic error

C. Logic error

22

Given the following statements:
If intGuess=intSelected Then
lblMessage.Text="Correct"
Else
lblMessage.Text="Incorrect"
End If
What is displayed when intGuess is 8 and intSelected is 9?
A. Correct on one line and Incorrect on the next line
B. Nothing would be displayed
C. Correct
D. Incorrect

D. Incorrect

23

What is a purpose of the WATCH window?
A. To display online help
B. To switch to the Code window
C. To display the application interface
D. To examine values during the execution of a program

D. To examine values during the execution of a program

24

The loop structure is also referred to as a(n)
A. Case
B. Block
C. Repetition
D. Decision

C. Repetition

25

The reason to use a breakpoint is to:
A. Examine variables and check logic.
B. Verify code syntax.
C. Evaluate the user interface.
D. Set the tab order for controls.

A. Examine variables and check logic.

26

How do you declare a variable whose value cannot be changed after assignment?
A. Replace Dim with Static
B. Declare the variable as a global variable
C. Add Const after Dim
D. Replace Dim with Const

D. Replace Dim with Const

27

Use a For..Next loop when theloop is to repeat the instructions how many times?

A. Fixed
B. Unrestricted
C. Infinite
D. Unlimited

A. Fixed

28

Given the following statements:
Dim intNum As Integer = 0
Do
IntNum = intNum + 1
Loop While intNum

C. 5

29

A meat packer grades meat "P" for Prime, "C" for Choice, "S" for Standard, and "G" for Good. Which Caseexpression will represent ChoiceMeat?
A. Case "P", "S"
B. Case "CGSP"
C. Case "C"
D. Case Else

B. Case "CGSP"
C. Case "C"

30

Grades are based on the scale below. Using this scale, which condition(s) would be used to identify students who made an "A" or a "B"?
A 93-100
B 85-92
C 78-84
D 70-77
F 0-69
A. dblScore = 93
B. dblScore = 85 Or dblScore > 93
C. dblScore >= 85
D. dblScore > 85 And dblScore >= 90

C. dblScore >= 85

31

Which statement generates random whole numbers greater than or equal to 10 and less than 51, given thefollowing code?
Dim gen As New System.Random()

A. gen.Next(10, 51)
B. gen.Next(10, 50)
C. gen.Next(9, 51)
D. gen.Next(9, 50)

A. gen.Next(10, 51)

32


Which condition below is keyed correctly?
A. Case 2 - 5
B. Case 2 And 5
C. Case 2, 5
D. Case 2 Or 5

C. Case 2, 5

33

In the following code, how many times does the program count through the loop structure? For intCounter as
integer = 1 To 9 Step 3
A. 9
B. 1
C. 0
D. 3

D. 3

34

Which method formats output as currency?
A. dblMoney.ToString = $##.00
B. dblMoney.ToString("$##.00")
C. dblMoney.ToString($##.00)
D. dblMoney.ToString = "$##.00

B. dblMoney.ToString("$##.00")

35

Kirk wants to delcare a variable that holds its value beyond the normal lifetime. How should he declare it?
A. Dim Static intGrade As Integer
B. Dim intGrade As Integer
C. Static intGrade As Integer
D. Static Dim intGrade As Integer

C. Static intGrade As Integer

36

Which condition below is keyed correctly?
A. Case = 11 >

B. Case 11 To 33

37

If there are 6 sides on a die, which statement generates a random whole number to represent one of the sides,given the following code?
Dim gen As New System.Random()
A. gen.Next(6)
B. gen.Next(1, 7)
C. gen.Next(0,7)
D. gen.Next(1, 6)

B. gen.Next(1, 7)

38

Which condition below is keyed correctly?
A. Case Is 10
B. Case = 10
C. Case To 10
D. Case 10

D. Case 10

39


The words "A Double data type should be always stored as a Double data type!" would be best stored in which one of the following data types?
A. Double
B. String
C. Integer
D. Decimal

B. String