Cisc 113 : Intro to Visual Basic Final Exam

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Which of the following is true?

"Cat" < "cat"

Which statement is true?

"GMC" <= "GMC"

Which statement is false?

"Oldsmobile" < "Oldsmobile"

What will be the output of the following statement? txtBox.Text = (1234.567).ToString("C")

$1,234.57

The symbol for the string concatenation operator is

&

Visual Basic access keys are created by using which symbol in a button's Text property?

&

Which of the following arithmetic operations has the highest level of precedence?

()

Which of the following is a valid Visual Basic conditional statement?

(2 < n) Or (n < 5)

What is displayed when the button is clicked on? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim a, b as String Dim x as Integer a = "How now brown cow." b = "brown" x = FindIt(a, b) txtBox.Text = CStr(x) End Sub Function FindIt(z1 as String, z2 as String) As Integer Dim x as Integer x = z1.IndexOf(z2) End Function

0

What is the default tab index of the first object placed on a form?

0

What will be the output of the following program when the button is clicked on? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim var1, var2, num As Integer var1 = 2 var2 = 4 num = 6 Add(num) txtBox.Text = CStr(num) End Sub Sub Add(ByRef num As Integer) Dim var1, var2 As Integer num = var1 + var2 End Sub

0

What will be the output of the following program when the button is clicked? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim x, y, z As Double x = 3 y = 3 If x > y Then z = x + y Else z = y - x End If txtBox.Text = CStr(z) End Sub

0

What will be the output of the following program when the button is clicked? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim x, y, z As Double x = 3 y = 3 If x > y Then z = x + y Else z = y - x End If txtBox.Text = CStr(z) End Sub

0

Which of the following masks is appropriate for a masked text box into which the user will enter a license plate consisting of two digits followed by 4 letters?

00LLLL

Suppose there are four radio button controls attached to a group box control on a form. How many radio buttons can be selected (that is, be "on") at any given time?

1

Suppose there are four radio button controls attached to a group box control on a form. How many radio buttons can be selected (that is, be "on") at any given time? 2

1

What will be displayed when the following program segment is executed? Dim temp() As String = IO.File.ReadAllLines("Data.txt") Dim n As Integer = temp.Count - 1 Dim a(n) As Double For k As Integer = 0 To n a(k) = CDbl(temp(i)) Next txtBox.Text = CStr(a(3)) Assume the five rows of the file Data.txt contain the following entries: 3, 2, 5, 1, 4.

1

What will be the output of the following statement? txtBox.Text = (1234.56789).ToString("N3")

1,234.568

Which of the numbers below is equivalent to 0.000017489?

1.7489E-05

What is the value of numVar after the following three statements are executed? Dim numVar As Integer = 5 numVar = numVar + 2 numVar += 3

10

Consider the following Sub procedure. Sub TruncateSum(var1 As Double, var2 As Double, var3 As Double) txtBox.Text = CStr(Int(var1 + var2 + var3)) End Sub What will be the output when TruncateSum is used in the following lines of code? Dim num1, num2, num3 As Double num1 = 3.5 num2 = 6.75 num3 = 1 TruncateSum(num1, num2, num3)

11

What is the output of the following program segment? Dim temp() As String = IO.File.ReadAllLines("Data.txt") Dim n As Integer = temp.Count - 1 Dim numbers(n) As Double, h As Double = 0 For i As Integer = 0 To n numbers(i) = CDbl(temp(i)) Next For k As Integer = 0 to n h += numbers(k) Next txtBox.Text = CStr(h) Assume the four rows of the file Data.txt contain the following entries: 2, 4, 2, 3

11

What is the output of the following program segment? Dim nums(8) As Integer Dim total As Double = 0 For i As Integer = 0 To 8 nums(i) = i Next For k As Integer = 1 To 4 total += 10 ^ nums(k) Next txtBox.Text = CStr(total)

11110

Suppose the Double variable num has the value 123.4567. What value will the following statement assign to num? num = Math.Round(num, 2)

123.46

What is the output of the following program when the button is clicked on? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim result As Double Dim number(4) As Double FillArray(number) result = SumArray(number) txtBox.Text = CStr(result) End Sub Sub FillArray(ByRef anyArray() As Double) Dim temp() As String = IO.File.ReadAllLines("Data.txt") For i As Integer = 0 To 4 anyArray(i) = CDbl(temp(i)) Next End Sub Function SumArray(anyArray() As Double) As Double Dim total As Double total = 0 For i As Integer = 0 To 4 Step 2 total += anyArray(i) Next Return total End Function Assume the five rows of the file Data.txt contain the following entries: 1, 3, 5, 7, 9

15

What is the value of ("12/15/09").Substring(3,2)?

15

What numbers are displayed in the list box by the following program segment? Dim numbers As String = "1492,1776,1945" Dim temp() As String = numbers.Split(","c) Dim nums(2) As Integer For i As Integer = 0 to 2 nums(i) = CInt(temp(i)) Next lstBox.Items.Add(nums(1)) lstBox.Items.Add(nums.First)

1776 and 1492

Given x = 3 and y = 1, what value will be assigned to the Double variable w when the following statement is executed? w = (x + y) / (x - y)

2

In the line of code Dim scores() As Integer = {55, 33, 12} the upper bound of the array scores is which of the following?

2

What will be displayed when the following lines are executed? Dim x As Double = 2 'x = 3 txtBox.Text = CStr(x)

2

What will be the contents of the variable x after the following statement is executed? x = Math.Sqrt(((9 + 7) / (4 * 2)) + 2)

2

What will be the output of the following lines of code? Dim phrase As String = "A penny saved is worth nothing." If phrase.IndexOf("pen") <> -1 Then txtBox.Text = CStr(phrase.IndexOf("pen")) Else txtBox.Text = CStr(-1) End If

2

Which of the following is the same as 2 ^ 3? (A) 2 * 2 * 2 (B) 2 * 3 (C) 2 + 2 + 2 (D) 3 * 3

2 * 2 * 2

What numbers are displayed in the list box when the button is clicked on? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim file As String = "Beatles.txt" Dim fabFour() As String = FillArray(file) lstBox.Items.Add(Array.IndexOf(fabFour, "Ringo") lstBox.Items.Add(fabFour.Count - 1) End Sub Function FillArray(file As String) As String() Dim names() As String = IO.File.ReadAllLines(file) Return names End Function Assume the four lines of the file Beatles.txt contain the following entries: John, Paul, Ringo, George.

2 and 3

Suppose you are 20 years old, num is an integer variable, and the statement num = 1 + CInt(InputBox("How old are you?")) is executed and responded to? What will be the output of txtBox.Text = num & " years old"

21 years old

What is the output of the following program segment? Dim c As Double Dim temp() As String = IO.File.ReadAllLines("Data1.txt") Dim n As Integer = temp.Count - 1 Dim a(n) As Double For i As Integer = 0 To n a(i) = CDbl(temp(i)) Next temp() = IO.File.ReadAllLines("Data2.txt") Dim b(n) As Double For i As Integer = 0 To n b(i) = CDbl(temp(i)) Next For k As Integer = 0 To n If a(k) = b(k) Then c += 1 End If Next lstBox.Items.Add(c) Assume the twenty rows of the file Data1.txt contain the following entries: 3, 2, 5, 1, 7, 8, 3, 5, 6, 2, 3, 6, 1, 6, 5, 5, 7, 2, 5, 3. Assume the twenty rows of the file Data2.txt contain the following entries: 5, 3, 3, 4, 8, 2, 3, 5, 9, 5, 3, 7, 3, 7, 6, 3, 2, 1, 3, 4.

3

What will be displayed by the following program when the button is clicked? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim a, b, c, x As Double a = 5 b = 3 c = 6 If a > c Then x = 1 Else If b > c Then x = 2 Else x = 3 txtBox.Text = CStr(x) End If End If End Sub

3

What will be displayed by the following program when the button is clicked? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim a, b, c, x As Double a = 5 b = 3 c = 6 If a > c Then x = 1 Else If b > c Then x = 2 Else x = 3 txtBox.Text = CStr(x) End If End If End Sub

3

What will be displayed when the button is clicked? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim num As Double = 9 Dim sqrRoot As Double If num < 0 Then MessageBox.Show("Cannot find square root. Result set to zero.", "Error") sqrRoot = 0 Else sqrRoot = Math.Sqrt(Num) End If txtBox.Text = CStr(sqrRoot)) End Sub

3

What will be displayed when the button is clicked? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim num As Double = 9 Dim sqrRoot As Double If num < 0 Then MessageBox.Show("Cannot find square root. Result set to zero.", "Error") sqrRoot = 0 Else sqrRoot = Math.Sqrt(Num) End If txtBox.Text = CStr(sqrRoot) End Sub

3

What will be the output of the following program when the button is clicked on? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim number As Double = 3 DoubleAndSquare(number) txtBox.Text = CStr(number) End Sub Sub DoubleAndSquare(ByRef myVar As Double) myVar = myVar + myVar myVar = myVar * myVar End Sub

36

What value will be assigned to the numeric variable x when the following statement is executed? x = 2 + 3 * 4

4

What two numbers are displayed in the list box when the button is clicked on? Dim nums() as Integer Private Sub frmNumbers_Load(...) Handles MyBase.Load nums(0) = 5 nums(1) = 3 nums(2) = 4 End Sub Private Sub btnDisplay_Click(...) Handles btnDisplay.Click lstBox.Items.Add(nums.Average) lstBox.Items.Add(nums.Max) End Sub

4 and 5

What will be displayed when the button is clicked on? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim lng, wid As Double lng = 5 wid = 10 ComputeArea(lng, wid) End Sub Sub ComputeArea(length As Double, width As Double) Dim area As Double area = length * width txtBox.Text = CStr(area) End Sub

50

What will be the output of the following statement? txtBox.Text = (2/3).ToString("P4")

66.6667%

Asc("A") is 65. What is Asc("C")?

67

Asc("A") is 65. What is Asc("C")?

67

What will be the value of numVar when the following code is executed Dim strVar As String, numVar As Integer strVar = "Now is the time for all good men" numVar = strVar.IndexOf("the time for")

7

What will be the output of the following program when the button is clicked on? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim num As Integer = 10 DisplayMult(num) num = 5 DisplayMult(num) num = 2 DisplayMult(num) End Sub Sub DisplayMult(num As Integer) If num <= 3 Then txtOutput.Text &= CStr(3 * num) Else If num > 7 Then txtOutput.Text &= CStr(7 * num) End If End If End Sub

706

After the following Dim statement is executed, how many elements will the array myVar have? Dim myVar(7) As Double

8

What is the value of Int(8.9)?

8

txtBox.Text = CStr(Math.Round(17 / 2))

8

What will be displayed when the following lines are executed? Dim x As Double = 3, y As Double = 1 Dim z As Double z = x + (y * x) x = y z = x + z lstBox.Items.Add(x + y + z)

9

An algorithm is defined as:

A logical sequence of steps that solve a problem

Which of the following is NOT considered part of a good top-down design chart?

A module should accomplish as many tasks as possible.

Sizing Handles make it very easy to resize virtually any control when developing programs with Visual Basic. When working in the Form Designer, how are these sizing handles displayed?

A rectangle with small squares around your control

What will be the output when the button is clicked on? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim first, middle, last As String first = "Augusta" middle = "Ada" last = "Byron" Initials(first, middle, last) End Sub Sub Initials(c As String, b As String, a As String) Dim theInitials As String theInitials = a.Substring(0, 1) & b.Substring(0, 1) & c.Substring(0, 1) txtBox.Text = theInitials End Sub

AAB

What is the output of the following program when the button is clicked on? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim a, b As String txtBox.Clear() a = "A" b = "B" PrintWords(a, b) PrintWords(b, a) End Sub Sub PrintWords(a As String, b As String) txtBox.Text &= a & b End Sub

ABBA

Asc("A") is 65. What is displayed by txtBox.Text = Chr(65) & "BC"?

ABC

Asc("A") is 65. What is displayed by txtBox.Text = Chr(65) & "BC"?

ABC

The input to a user-defined function can consist of:

All of the above

What type of items are valid for use in the value list of a Case clause?

All of the above

When will the following event procedure be executed? Private Sub txtBox_TextChanged(...) Handles txtBox.TextChanged

All of the above

Which value for x would make the following condition true: x >= 5

All of the above

The three main logical operators are ________, _________, and ________.

And, Or, Not

Which one of the following is true about arguments and parameters?

Arguments appear in calling statements; parameters appear in Sub statements.

What feature in Visual Basic allows you to make more room on your screen by temporarily minimizing certain windows?

Auto hide

Which value for x would make the following condition true: (x >= 5) And (x <= 6)

B and C

Which value for x would make the following condition true: (x >= 5) And (x <= 6)

B and C

Consider the following event procedure that calls a Function procedure named Cube, which returns the cube of a number. Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim num, result As Double num = CDbl(InputBox("Enter a number to cube:")) result = Cube(num) txtBox.Text = "The cube of " & num & " is " & result & "." End Sub Which of the following is a correct Function definition for Cube? 1. Function Cube(var As Double) As Double Return var ^ 3 End Function 2. Function Cube(num As Double) As Double Return num ^ 3 End Function

Both 1 and 2

When using the logical operator "And", what part of the expression must be true?

Both parts

What names are displayed in the list box when the button is clicked on? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim names() As String = IO.File.ReadAllLines("Data.txt") lstBox.Items.Clear() For i As Integer = (names.Count - 1) To 0 Step -2 lstBox.Items.Add(names(i)) Next End Sub Assume the five lines of the file Data.txt contain the following entries: Bach, Borodin, Brahms, Beethoven, Britain.

Britain, Brahms, and Bach

What keyword in the header of a sub procedure denotes that a variable is passed by reference?

ByRef

What will be displayed when the button is clicked on? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim x, y As String x = "tin" y = "can" Swap(x, y) txtOutput.Text = x & " " & y End Sub Sub Swap(ByRef x As String, y As String) Dim temp As String temp = x x = y y = temp End Sub

Can can

Which Case clause will be true whenever the value of the selector in a Select Case block is between 1 and 5 or is 8?

Case 1 To 5, 8

Which Case clause will be true whenever the value of the selector in a Select Case block is greater than or equal to 7?

Case Is >= 7

Suppose that the selector in a Select Case block is the string variable myVar. Which of the following is NOT a valid Case clause?

Case myVar.Length

Which of the following is true?

Cat" < "cat"

When the user clicks on a check box control at run time, which one of the following events is raised (in addition to the Click event)?

Checkchanged

The default event procedure for a check box is _______

CheckedChanged

The default event procedure for a check box is _______ .

CheckedChanged

When the user clicks on a check box control at run time, which one of the following events is raised (in addition to the Click event)?

CheckedChanged

Which of the following expressions has as its value the words "Hello World" surrounded by quotation marks?

Chr(34) & "Hello World" & Chr(34)

Which of the following names would be best for the following Function (called NoName)? Function NoName(number As Double) As Double Return number ^ 3 + number ^ 3 End Function

CubeAndDouble

Which of the following statements declare the variables a and b as type Integer?

Dim a, b As Integer

What is the correct statement when declaring and assigning the value of 100 to an Integer variable called numPeople?

Dim numPeople As Integer = 100

What will be the output of the following program when the button is clicked on? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim word As String word = "progression" Strange(word) End Sub Sub Strange(var As String) txtBox.Text = var.Substring(CInt(Int(var.Length / 2)), 1) End Sub

E

What will be displayed when the following lines are executed? Dim a, b, c As String a = "THE WHOLE" b = "PART" c = a.Substring(CInt(Math.Sqrt(4)), b.Length) txtBox.Text = CStr(c)

E WH

Each individual variable in the list student(0), student(1), student(2) is known as a(n)

Element

When the user clicks a button, _________ is raised.

Event

What keyboard shortcut is used to run the current program?

F5

A top-down chart is the same thing as a flowchart.

False

Changing a control's Text property also changes how you refer to the control in code.

False

Clicking on a checked radio button unchecks the radio button

False

During the design phase, all errors will be caught by Visual Basic's smart editor.

False

Every If block must have a Then and an Else

False

F5 is the keyboard shortcut used to activate the Properties window.

False

Given that x = 7, y = 2, and z = 4, the following If block will display "TRUE". (T/F) If (x > y) And (y > z) Then txtBox.Text = "TRUE" End If

False

If a problem is very complex, extensive design prior to coding will actually delay the completion of the project

False

If you set a group box control's Visible property to False, the attached controls will remain visible (T/F)

False

In Visual Basic, the letter j is considered to be greater than the letter y. (T/F)

False

In most cases, a well-written program need not be tested.

False

In the line of code Function Sum(scores() As Integer) As Integer the pair of parentheses that follows scores can be removed. (T/F)

False

No more than one ElseIf statement may occur in any one If block

False

Numeric variables can be initialized to zero or any other number, but once they are initialized, they cannot be changed. (T/F)

False

Often a problem is too difficult to understand until one writes the program

False

Once a text box control is placed on a form, it cannot be resized or moved

False

Programmers frequently write event procedures for the group box control. (T/F)

False

Software refers to the people who work with computer hardware

False

The ForeColor property of a text box changes the color of the form containing the text box

False

The Properties window cannot be used to display the events associated with a control

False

The condition "Y" = "y" is true. (T/F)

False

The control with tab index 1 is always the first control to receive the focus when the program is run

False

The exponential notation used in Visual Basic is exactly the same as standard mathematical notation

False

The following condition evaluates to True. (T/F) ("DOG" > "CAT") And ("CAT" > "BIRD") And ("BIRD" > "aardvark")

False

The following line of code is valid. (T/F) If 0 ≤ grade ≤ 100 Then

False

The following lines of code are correct. (T/F) If (txtAge.Text >= 62) Then txtOutput.Text = "You are elegible to collect Social Security." End If

False

The following lines of code are correct. (T/F) If age >= 13 And < 20 Then txtOutput.Text = "You are a teenager." End If

False

The following lines of code are valid. (T/F) Private Sub Click(...) Handles Click txtBox.Text = "" End Sub

False

The following statement assigns 6 times the value of y to x. (T/F) x = 6y

False

The following statement is valid. (T/F) Dim x As Double = 3,542.36

False

The following two statements are equivalent, where numVar is a numeric variable. (T/F) numVar = numVar + 1 numVar += 1

False

The following two statements are equivalent. (T/F) Not (a < b) a > b

False

The following two statements are equivalent. (T/F) var1 = var2 var2 = var1

False

The statement a + b = c assigns to c the sum of the values of a and b

False

The statement txtBox.Text = Chr(162) causes Visual Basic to display the cents symbol (ANSI 162) in the text box, regardless of the font in use. (T/F)

False

The value of "education".StartsWith("ED") is True. (T/F)

False

The value of (11 \ 2) is 1.

False

The value returned by a Function procedure must be a number or a string. (T/F)

False

Visual Basic first appeared about ten years ago

False

When starting a new program, it is best to start writing code as soon as possible to avoid wasting time thinking about it

False

Based on what it returns, what would be a better name for the function "Mystery" in the following program? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim sentence As String, result As String sentence = "Socrates is a man." result = Mystery(sentence) txtBox.Text = result End Sub Function Mystery(sentence As String) As String Dim position As Integer position = sentence.IndexOf(" ") Return sentence.Substring(0, position) End Function

FirstWord

Flowcharts, pseudocode, and top-down charts can be used to solve problems only in Visual Basic.

Flase

The value of IsNumeric("Twenty") is True. (T/F)

Flase

A graphical depiction of the logical steps to carry out a task and show how the steps relate to each other is called a(n)

Flowchart

Given the Dim statement below, which set of statements will initialize all elements of myArray to 100? Dim myArray(100) As Double (A) myArray = 100 (B) For i As Integer = 0 To 100 (i) = 100 Next (C) For j As Integer = 0 to 100 myArray(j) = 100 Next (D) myArray() is already initialized to 100 by the Dim statement.

For j As Integer = 0 to 100 myArray(j) = 100 Next

What will be the output of the following program when the button is clicked? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim word1, word2, newWord As String word1 = "shower" word2 = "about" newWord = word1.Substring(0, 4) & word2.Substring(0, 3) If newWord.IndexOf("how") = -1 Then txtBox.Text = "The new word was not found." Else txtBox.Text = "Found it." End If End Sub

Found

What will be the output of the following program when the button is clicked? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim word1, word2, newWord As String word1 = "shower" word2 = "about" newWord = word1.Substring(0, 4) & word2.Substring(0, 3) If newWord.IndexOf("how") = -1 Then txtBox.Text = "The new word was not found" Else txtBox.Text = "Found it." End If End Sub

Found it

What word(s) will appear in the list box when the button is clicked? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim num As Integer = 5 If num = 2 Then lstBox.Items.Add("Two") ElseIf num > 3 Then lstBox.Items.Add("Great") ElseIf num = 5 Then lstBox.Items.Add("Equal") End If End Sub

Great

A collection of related radio buttons is usually placed in a _______ .

Groupbox

A(n) _____________ allows a program to decide on a course of action based on whether a certain condition is true or false.

If Block

A(n) _____________ allows a program to decide on a course of action based on whether a certain condition is true or false.

If block

The Font dialog box allows you to select different Fonts, their style, their size, and some other special effects. How do you bring up this Font dialog box?

In the Properties window, click the ellipsis (...) on the right side of the settings box for the Font property

What happens to a variable declared locally inside a Sub procedure after the procedure terminates?

It ceases to exist after the End Sub statement executes.

Suppose a variable is passed by reference to a parameter of a Sub procedure, and the parameter has its value changed inside the Sub procedure. What will the value of the variable be after the Sub procedure has executed?

It will have the newly modified value from inside the Sub procedure.

Suppose a variable is passed by value to a parameter of a Sub procedure, and the parameter has its value changed inside the Sub procedure. What will the value of the variable be after the Sub procedure has executed?

It will retain the value it had before the call to the Sub procedure.

Which of the tasks is the Join function used to carry out in the following statement? Dim line As String line = Join(strArrData, ",") (A) Join concatenates the values of all elements of the array strArrData, and adds a comma delimiter between successive values. (B) Join concatenates the values of all elements of line, and adds a comma to the end of the line. (C) Join parses or separates out all items of text that are delimited by a comma in strArrData. (D) Join parses or separates out all items of text that are delimited by a comma in line.

Join concatenates the values of all elements of the array strArrData, and adds a comma delimiter between successive values.

What effect will the following statement have? lblOne.Visible = False

Make lblOne invisible

What names are displayed in the list box by the following program segment? Dim newYork As String = "Manhattan,Bronx,Brooklyn,Queens,Staten Island" Dim boroughs() As String = newYork.Split(","c) lstBox.Items.Add(boroughs(0)) lstBox.Items.Add(borought.Min)

Manhattan and Bronx

Which of the following statements will place "Greetings" in the title bar of a form?

Me.Text = "Greetings"

What of the following is a correct statement for specifying the words to appear in the title bar of Form1?

Me.Text = "My Text"

Which of the following is a valid statement in Visual Basic?

Me.Text = "Revenue"

MessageBox.Show Hi There, Hi

MessageBox.Show statement

What is the proper syntax when using a message dialog box?

MessageBox.Show("Hi there", "Hi")

Which of the properties in a control's list of properties is used to give the control a meaningful name?

Name

Constructs in which an If block is contained inside another If block are called

Nested IF block

Which of the following techniques always toggles the "on" and "off" states of a radio button control?

None of the Above

Which of the following techniques always toggles the "on" and "off" states of a radio button control?

None of the above

What is the key difference between a group of check boxes attached to a group box and a group of radio buttons attached to a group box?

Only one radio button at a time can be checked

What is the key difference between a group of check boxes attached to a group box and a group of radio buttons attached to a group box?

Only one radio button at a time can be checked.

The process of transmitting values to a Sub procedure is known as ______________.

Passing

n Visual Basic, tooltips assist by showing a small caption about the purpose of each icon on the Toolbar. How do you make a tooltip appear?

Position the mouse pointer over the icon for a few seconds

A collection of lines of instruction is called a(n)

Program

What names are displayed in the list box when the button is clicked on? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim file As String = "Ships.txt" Dim ships() As String = FillArray(file) lstBox.Items.Add(ships(2)) lstBox.Items.Add(ships.Min) End Sub Function FillArray(file As String) As String() Dim names() As String = IO.File.ReadAllLines(file) Return names End Function Assume the three lines of the file Ships.txt contain the following entries: Pinta, Nina, Santa Maria.

Santa Maria and Nina

The default event procedure for a list box is _______

SelectedIndexChanged

The default event procedure for a list box is _______ .

SelectedIndexChanged

Which of the following techniques does NOT always toggle the checked and unchecked state of a check box control?

Set the Checked property equal to 1

Which of the following techniques does NOT always toggle the checked and unchecked state of a check box control?

Set the Checked property equal to 1.

Which of the following steps specifies P as the access key for a button?

Set the Text property to Com&pute

At design time, values can be placed into a list box via the

String Collection Editor

At design time, values can be placed into a list box via the _______ .

String Collection Editor

When a Visual Basic program is running, the user can move from one control to another using the keyboard by pressing the

Tab Key

What property of controls tells the order they receive the focus when the tab key is pressed during run time?

Tab index

What property of a control determines whether the control can receive the focus during run time?

TabStop

The title (as seen by the user) for the group box control is set by which one of the following properties?

Text

Which of the following properties determines the words appearing in a form's title bar?

Text

A check box control named chkFirst contains the following code in its CheckedChanged event procedure. Which of the following is true concerning the use of this control? Dim message As String = "hello" MessageBox.Show(message)

The message "hello" will appear when the user checks the control and again when it is unchecked

A check box control named chkFirst contains the following code in its CheckedChanged event procedure. Which of the following is true concerning the use of this control? Dim message As String = "hello" MessageBox.Show(message

The message "hello" will appear when the user checks the control and again when it is unchecked.

Which statement is true regarding the following Dim statement? Dim states(49) As String, populations(49) As Double

The subscripts of populations range from 0 To 49.

Consider the following two sets of code. (a) If (a = 1) And (b = 1) Then txtBox.Text = "Hi" End If (b) If a = 1 Then If b = 1 Then txtBox.Text = "Hi" End If End If Which one of the following statements is true?

The two sets of code are equivalent, but (a) is preferred to (b) because (a) is clearer.

Consider the following two sets of code. If (a = 1) And (b = 1) Then B. If a = 1 Then txtBox.Text = "Hi" If b = 1 Then End If txtBox.Text = "Hi" End If End If Which one of the following statements is true?

The two sets of code are equivalent, but A is prefered to B. because A is clearer

Suppose the variable myName is declared in a Dim statement in two different Sub procedures. Which statement is true?

The two variables will be local to their respective Sub procedures.

What will be the output of the following program when the button is clicked on? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim word1, word2, word3, result As String word1 = "The" word2 = "English" word3 = "Channel" CatWords(word1, word2, word3, result) txtBox.Text = result End Sub Sub CatWords(var1 As String, var2 As String, word3 As String, ByRef final As String) final = var1 & var2 & word3 End Sub

TheEnglishChannel

Which of the following is not a logical operator in Visual Basic?

Then

What is the problem (if any) with the following Select Case block which is intended to determine the price of a movie depending on the patron's age? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim age as Integer, price As Double age = CInt(InputBox("Enter your age:")) Select Case age Case Is >= 65 'Senior citizen price = 4.50 Case Is >= 5 'Regular price price = 6.00 Case Is >= 0 'Child (no charge with parents) price = 0 Case Else txtBox.Text = "Entry error" End Select End Sub

There is nothing wrong

What is the problem (if any) with the following Select Case block which is intended to determine the price of a movie depending on the patron's age? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim age as Integer, price As Double age = CInt(InputBox("Enter your age:")) Select Case age Case Is >= 65 'Senior citizen price = 4.50 Case Is >= 5 'Regular price price = 6.00 Case Is >= 0 'Child (no charge with parents) price = 0 Case Else txtBox.Text = "Entry error" End Select End Sub

There is nothing wrong

Why is the following Select Case block invalid in Visual Basic? Select Case myName.Substring(0, 1) Case myName < "D" txtBox.Text = "Your name starts with A, B, or C." End Select

There should not be a standard conditional expression in a value list

Why is the following Select Case block invalid in Visual Basic? Select Case myName.Substring(0, 1) Case myName < "D" txtBox.Text = "Your name starts with A, B, or C." End Select

There should not be a standard conditional expression in a value list.

Which of the following is NOT a reason for using procedures?

They make a program run faster.

What will be the output of the following program when the button is clicked on? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim word1, word2, word3 As String word1 = "First" word2 = "Second" word3 = "Third" Myproc(word1, word2, word3) End Sub Sub Myproc(var3 As String, var2 As String, var1 As String) txtBox.Text = var1 & var2 & var3 End Sub

ThirdSecondFirst

What message will be displayed by the following statement: MessageBox.Show("This is a test.", "Test")

This is a test.

"1st Place" < "2nd Place" (T/F)

True

< and = are examples of relational operators. (T/F)

True

A flowchart is an arrangement of geometric shapes connected by arrows.

True

A group of several controls can be resized or moved simultaneously

True

A mouse click is an example of an event.

True

A numeric variable that has not been assigned a value has the default value zero.

True

A radio button named radButton is placed on a form, and the statement MessageBox.Show(radButton.Checked) is placed in its CheckedChanged event procedure. At run time, what result will be displayed in the message box when the user clicks on radButton?

True

A single Case statement can contain multiple values (T/F)

True

A variable declared inside a Select Case block cannot be referred to by code outside of the block. (T/F)

True

A variable declared inside an If block ceases to exist after the block is exited. (T/F)

True

After several controls of the same type have been created, they can be moved inside a group box and thereby become attached to it. (T/F)

True

Although a flowchart (as its name suggests) depicts data flow very well, it is not easily modified once written.

True

Although the documentation step is usually listed last in the problem-solving process, it should actually begin when the problem is first defined and continue through the problem-solving process.

True

An assignment statement is used to assign a value to a variable or property

True

As with the button and check box controls, an access key can be set up by placing an ampersand in front of a letter in the radio button's Text property setting. (T/F)

True

Clicking on a checked check box unchecks the check box

True

Complete Word is a helpful feature produced by the Microsoft Technology called IntelliSense

True

Conditions can involve variables, operators, and functions.

True

Every Select Case block can be replaced by If blocks.

True

Function procedures can call other Function procedures. (T/F)

True

Given that x = 7, y = 2, and z = 4, the following If block will display "TRUE". (T/F) If (x > y) Or (y > z) Then txtBox.Text = "TRUE" End If

True

Group boxes are passive objects used to group related sets of controls

True

If strVar.Length is 5, then the value of strVar.Substring(4, 1) is the last character of the value of strVar. (T/F)

True

If two simple conditions are true, the compound condition created from them by the And operator is also true. (T/F)

True

If two simple conditions are true, the compound condition created from them by the Or operator is also true. (T/F)

True

Items in the value list must evaluate to a literal of the same type as the selector. (T/F)

True

Keywords are also referred to as reserved words

True

No more than one Else statement may occur in any one If block

True

Once a control is placed on your form, you can rename it by editing the Name property in the Properties window

True

One may use a Select Case block within an If block

True

One may use a Select Case block within another Select Case block. (T/F)

True

One may use an If block within a Select Case block

True

Pseudocode and flowcharts are two different tools or methods used in planning a solution to a problem

True

Select Case choices are determined by the value of an expression called a selector. (T/F

True

Shortcut keys like F5 (Run), allow you to perform certain tasks without the use of the mouse

True

Snap lines can be used to align the bottoms, middles, and tops of controls.

True

Suppose a form contains two group box controls with one radio button placed on each. In this case, both radio buttons can be selected (or turned "on") at the same time. (T/F)

True

Suppose your supervisor at work wants you to write a program to accomplish a task that he has specified. However, he has not let you know which computer language to use. It is still possible to design the program in pseudocode

True

The And operator requires that both conditions be true for the compound condition to be true. (T/F)

True

The Auto Hide feature of the Toolbox is active when the pushpin is horizontal. (T/F)

True

The Case Else part of a Select Case block is optional. (T/F)

True

The Description pane, located below the Properties windows, shows a brief explanation of the highlighted property

True

The Else part of an If block may be omitted if no action is associated with it. (T/F)

True

The Properties window is used to change how objects look and react

True

The Visual Basic Code Editor automatically capitalizes the first letters of reserved words

True

The Visual Basic Code Editor will automatically detect certain types of errors as you are entering code.

True

The analysis and design steps of program planning are largely independent of the particular computer language the programmer is using

True

The divide-and-conquer-method of problem solving breaks a problem into large, general pieces first, then refines each piece until the problem is manageable

True

The first line of an event procedure must contain both the keyword Sub and Handles

True

The following statement is valid. (T/F) y = y + 72

True

The function Math.Int will always round mixed numbers down to the next lowest integer.

True

The key combination Shift + arrow key can be used to resize a control or a group of controls

True

The purpose of a test or decision in a looping structure is to tell when the loop should end

True

The recommended prefix for the name of a button control is btn.

True

The statement btnButton = "Press" produces an error message.

True

The statement txtBox.Font.Bold = True will produce an error message when Visual Basic tries to execute it.

True

The value of "education".EndsWith("on") is True. (T/F)

True

The value of (11 Mod 2) is 1

True

The value of IsNumeric("$20.00") is True. (T/F)

True

The value of lstBox.Text is the currently selected item of the list box. (T/F)

True

The variables firstName and firstNAME are identical

True

Two strings are compared working from left to right, character by character, to determine which one should precede the other. (T/F)

True

Visual Basic always displays numbers in decimal format

True

Visual Basic uses a graphical user interface

True

When a check box control has the focus, the spacebar can be used to invoke its CheckedChanged event. (T/F)

True

When a check box is checked, the value of the Checked property will be

True

When an If block has completed execution, the program instruction immediately following the If block is executed. (T/F)

True

When the button is clicked on, the output of the following program will be 5. (T/F) Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim x, y, result As Double x = 3 y = 4 result = CInt((Norm(x, y))) txtBox.Text = CStr(result) End Sub Function Norm(x As Double, y As Double) As Double Return Math.Sqrt(x^2 + y^2) End Function

True

When using the equal sign to assign values, the variable on the left hand side of the equal sign will always receive the value. (T/F)

True

When working with text boxes, the sizing handles allow you to resize the object by dragging to make it wider or narrower

True

With a check box control, toggling the state of the small square raises the CheckChanged event. (T/F)

True

You can display the Properties window by pressing F4

True

You can specify a range of values in a Case clause by using the To keyword

True

You can use a variable name in almost any place you could use a literal value

True

The following line of code is valid. (T/F) If letter = ("The quality of mercy is not strained").Substring(7, 1) Then

Trur

Which of the following is a valid name for a variable?

Two_One

What will be the output of the following program when the button is clicked? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim a, b, c, acronym As String a = "federal" b = "aviation" c = "administration" acronym = a.Substring(0, 1) & b.Substring(0, 1) & c.Substring(0, 1) Select Case acronym Case "FAA" txtBox.Text = "Federal Aviation Administration" Case "DEA" txtBox.Text = "Drug Enforcement Agency" Case Else txtBox.Text = "Unknown acronym. Sorry." End Select End Sub

Unknown acronym, sorry

What will be the output of the following program when the button is clicked? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim a, b, c, acronym As String a = "federal" b = "aviation" c = "administration" acronym = a.Substring(0, 1) & b.Substring(0, 1) & c.Substring(0, 1) Select Case acronym Case "FAA" txtBox.Text = "Federal Aviation Administration" Case "DEA" txtBox.Text = "Drug Enforcement Agency" Case Else txtBox.Text = "Unknown acronym. Sorry." End Select End Sub

Unknown acronym. Sorry

The person who actually runs a computer program is called a

User

Which property is available for most controls that allows you to hide/unhide them either manually by setting the property or by setting it during run time via code?

Visible

What will be the output of the following program when the button is clicked? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim name As String = "Washington" Select Case name Case "George" txtBox.Text = "George" Case "Wash" txtBox.Text = "Wash" Case "WASHINGTON" txtBox.Text = "WASHINGTON" Case Else txtBox.Text = "Washington" End Select End Sub

Washington

What will be the output of the following program when the button is clicked? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim name As String = "Washington" Select Case name Case "George" txtBox.Text = "George" Case "Wash" txtBox.Text = "Wash" Case "WASHINGTON" txtBox.Text = "WASHINGTON" Case Else txtBox.Text = "Washington" End Select End Sub

Washington

Which of the following is not a submenu of the Format menu?

Widen

When creating a new program in Visual Basic, you are asked to supply a name for the program. If you do not specify a name, a default name is used. What is this default name?

WindowsApplication followed by a number

Which value for x would make the following condition true: Not (x >= 5)

X is equal to 4

What will be displayed in the list box when the following code runs? Select Case num Case 6, 7, 11 lstBox.Items.Add("W") Case Is < 7 lstBox.Items.Add("X") Case Is > 5 lstBox.Items.Add("Y") Case Else lstBox.Items.Add("Z") End Select

Z can never be displayed

What will be displayed in the list box when the following code runs? Select Case num Case 6, 7, 11 lstBox.Items.Add("W") Case Is < 7 lstBox.Items.Add("X") Case Is > 5 lstBox.Items.Add("Y") Case Else lstBox.Items.Add("Z") End Select

Z can never be displayed.

In modular programming, a driver is

a "dummy" program designed solely to call a single procedure and examine its returned values.

Which of the following is not commonly used to allow the user to select among several options?

a collection of text boxes

Pseudocode is

a description of an algorithm similar to a computer language

Suppose in the very early stages of the problem-solving process, your supervisor wants you to show her the relationships between the various processes that will be needed to solve the problem. The best way to do this would be to use

a flowchart

Top-down design refers to

a program design where the key event procedures act like supervisors, delegating tasks to various Sub procedures.

What will be the output of the following lines? Dim alphabet, soup As String alphabet = "abcdefghijklmnopqrstuvwxyz" soup = alphabet.ToUpper txtBox.Text = alphabet.Substring(0, 5) & soup.Substring(0, 5)

abcdeABCDE

What will be the output of the following program when the button is clicked on? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim word As String word = "hairbrush" Decapitate(word) txtBox.Text = word End Sub Sub Decapitate(ByRef word As String) 'Chop the first letter off the word. word = word.Substring(1) End Sub

airbrush

A user action such as clicking a button is called

an event

Visual Basic responds to events using which of the following?

an event procedure

Which of the following is the proper order of procedures used in the problem-solving process?

analysis, design, coding, testing

The declaration statement for a class-level variable should be placed __________.

anywhere in the program region, except inside a procedure

What character is used to signify the beginning of a comment statement?

apostrophe

Items appearing in the parentheses of a calling statement are known as _______________.

arguments

Variables appearing inside the parentheses of a calling statement are called

arguments

IntelliSense is a technology built into Visual Basic that assists the programmer by

automatically displaying the methods and properties available to a control

The following statement contains what type of error? txtAverage.Txt = CStr(CDbl(txtNum1.Text) + CDbl(txtNum2.Text) / 2)

both a syntax error and a logic error

When using the logical operator "And", what part of the expression must be true?

both parts

Stepwise refinement refers to

breaking a large task into smaller tasks.

Which of the following statements sets the words on a button to "Push Me"?

btnButton.Text = "Push Me"

A variable or named constant that is visible to every procedure in a form's code without being passed is called a __________ variable.

class-level

Different items appearing in the same value list of a Select Case block must be separated by a ____________.

comma

The joining of two strings together to form a new string is called

concatenation.

What does the circle flowchart symbol represent?

connector

The process of finding and correcting errors in a program is called

debugging

What does the diamond flowchart symbol represent?

decision

In the line of code For index As Integer = 0 to (score.Count - 1) the Count method is used to carry out which of the following tasks?

determine the largest subscript in the array

Press F4 to

display the Properties window

Programming in VB 2012 is different from traditional programming environments because first you should

draw the user interface

When using the logical operator "Or", what part of the expression must be true?

either the left or right part

When declaring a variable that will refer to a submarine, a good name for the variable is sub

false

When the button is clicked, the output of the following program will be 20. (T/F) Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim num As Integer = 20 DoubleIt(num) txtBox.Text = CStr(num) End Sub Sub DoubleIt(ByRef var As Integer) var = var * 2 End Sub

false

GUI stands for

graphical user interface

A collection of related radio buttons is usually placed in a _______

groupbox

Keywords in Visual Basic are words that

have special meaning and should not be used when naming variables.

Visual Basic is considered to be a

higher-level language

What does the parallelogram flowchart symbol represent?

input/output

Which one of the following is NOT one of the three basic types of statement structures?

input/output

What will be the output of the following program when the button is clicked on? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim word, result As String word = "Benjamin" result = Rotate(word) result = Rotate(result & word) result = Rotate(result) txtBox.Text = result End Sub Function Rotate(var As String) As String Dim varlength As Integer varlength = var.Length Return var.Substring(1) & var.Substring(0, 1) End Function

jaminBBenjaminen

Variables and named constants declared inside a procedure are said to have ________________.

local scope

The operator And is a(n) _________ operator.

logical

If you are writing a program that needs to repeat a series of calculations, what programming structure should you use to repeat the calculations?

looping structure

Which of the following statements removes all text from lstBox?

lstBox.Items.Clear()

The statement btnButton.Focus()

moves the focus to the button btnButton

Which of the following expressions will yield the string "John Doe", where name1 = "John Blake" and name2 = "Janet Doe"?

name1.Substring(0, 5) & name2.Substring(6, 3)

Constructs in which an If block is contained inside another If block are called:

nested If blocks

A(n) __________ is an encapsulation of data and code that operates on the data

object

In a Select Case block, if more than one Case clause matches the selector,

only the statements associated with the first matching Case clause will be executed

In a Select Case block, if more than one Case clause matches the selector

only the statements associated with the first matching Case clause will be executed.

The ______________ of a Sub procedure are vehicles for passing numbers and strings to the Sub procedure

parameters

Variables appearing in the header of a Function procedure are called ____________.

parameters

What does the rectangle flowchart symbol represent?

process

Which of the following statements turns on the radio button radButton?

radButton.Checked = True

What two names are displayed in the list box when the button is clicked on? Dim krispies() as String Private Sub frmCereal_Load(...) Handles MyBase.Load krispies(0) = "snap" krispies(1) = "crackle" krispies(2) = "pop" End Sub Private Sub btnDisplay_Click(...) Handles btnDisplay.Click lstBox.Items.Add(krispies.Max) lstBox.Items.Add(krispies.Last) End Sub

snap and pop

Which of the following is not one of the three steps used to create a Visual Basic program?

specify the methods

What does the "rectangle with rounded sides" flowchart symbol represent?

start/stop

Breaking up a large problem into smaller subproblems is called _________________.

stepwise refinement

Which of the following is NOT considered to be one of the three basic features of a program?

store

Given the data assigned to the string variable str2 shown below, which of the following statements will assign the value ALL to the string variable str1?

str1 = str2.Substring(5, 3)

Which statement prompts the user for a name and then assigns the name to the string variable strName?

strName = InputBox("What is your first name?", "First Name")

Which of the following expressions has as its value the value of strVar with its leading and trailing spaces removed?

strVar.Trim

A program is said to be _________________ if it meets modern standards of program design.

structured

The type of error that is normally spotted by the Code Editor is:

syntax

Assume that x, y, and temp are Integer variables. Which of the following lines of code swaps the values of x and y?

temp = x x = y y = temp

"Desk-checking" refers to

testing an algorithm at the flowchart stage using several different kinds of data

The title (as seen by the user) for the group box control is set by which one of the following properties?

text

In the statement Dim scores(30) As Double the number 30 designates which of the following?

the highest value of the subscripts of the elements for the array scores

The Count method returns what information about an array?

the number of elements in the array

When an End Sub statement is reached in a Sub procedure, execution jumps to

the statement after the statement that called the Sub procedure.

The Properties window plays an important role in the development of Visual Basic programs. It is mainly used

to change how objects look and feel

Which of the following types of charts shows only the relationships between general program tasks without showing specific modules or directions for data flow?

top-down chart

A radio button named radButton is placed on a form, and the statement MessageBox.Show(radButton.Checked) is placed in its CheckedChanged event procedure. At run time, what result will be displayed in the message box when the user clicks on radButton?

true

The lstBox.Items.Clear() statement is used to empty the contents of a list box

true

Which of the following statements specifies that the color of the text in txtBox be red?

txtBox.ForeColor = Color.Red

Which statement can be used to clear the contents of a text box?

txtBox.Text = ""

Which of the following statements is a valid assignment statement? (A) txtBox = "Hello World" (B) "Hello World" = txtBox.Text (C) txtBox.Text = "Hello World" (D) Text.txtBox = "Hello World"

txtBox.Text = "Hello World"

Which statement will display the words "Hello World" in a text box?

txtBox.Text = "Hello" & " World"

Which of the following statements will NOT display the number 5 in the text box?

txtBox.Text = 5

What is the correct syntax for displaying the value of the String variable myString in a text box?

txtBox.Text = myString

Which of the following code statements generates an error?

txtFirst.Text = Hello

What would be a good name for a text box to hold a person's first name?

txtFirstName

What is wrong with the following calling statement and its corresponding Sub statement? MyProcedure("The Jetsons", 1000, 209.53) Sub MyProcedure(var1 As Double, var2 As Double, var3 As Double)

var1 is not of the same data type as "The Jetsons."

When is the expression "Not cond1" true?

when cond1 is false

Which value for x would make the following condition true: Not (x >= 5)

x is equal to 4

Which value for x would make the following condition true: x >= 5

x is equal to 7


संबंधित स्टडी सेट्स

7A p102 Can we make our own luck? (collocations)

View Set

Chapter 12: Inventory Management

View Set

Chapter 7 - Small Business Strategies - Imitation with a Twist

View Set

The Nose, Paranasal Sinuses, and Maxillary Nerve

View Set

44.1 Advertising, Marketing, and Sales

View Set