Deck 5: General Procedures

Full screen (f)
exit full mode
Question
A Function procedure may return up to two values.
Use Space or
up arrow
down arrow
to flip the card.
Question
Although a Function procedure can return a value, it cannot directly display information in a text box.
Question
A Function procedure need not have parameters.
Question
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)

A) It is not valid to pass something like "The Jetsons."
B) Constant values like 1000 cannot be passed, only variables.
C) var1 is not of the same data type as "The Jetsons."
D) Nothing is wrong with them.
Question
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

A) progr
B) r
C) e
D) progre
Question
Function names should be suggestive of the role performed. The names also must conform to the rules for naming variables.
Question
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

A) FirstWord
B) LastWord
C) FirstLetter
D) LastLetter
E) DoesNothing
Question
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

A) jaminBBenjaminen
B) BenjaminBenjamin
C) njaminBe
D) None of the above
Question
The header of a Function procedure must include parameters.
Question
When the button is clicked on, the output of the following program will be 5.
Private Sab btnDisplay_Click(...) Handles btnDisplay.Click
Dim x,yx , y , result As Double
x=3\mathbf { x } = 3
y=4\mathrm { y } = 4
result =CInt((Norm(x,y)))= \operatorname { CInt } ( ( \operatorname { Norm } ( x , y ) ) )
txtBox. Text =cstr(= \operatorname { cstr } ( result ))
End Sub
Function Norm(x As Double, y As Double) As Double
Return Math.Sqrt x ^ 2 + y ^ 2
End Function
Question
The value returned by a Function procedure must be a number or a string.
Question
The input to a user-defined function can consist of one or more values.
Question
Variables appearing inside the parentheses of a calling statement are called___________ .

A) values of the function
B) parameters
C) coordinates
D) arguments
Question
What is displayed when the button is clicked on? Private Sab btnDisplay_Click(...) Handles btnDisplay.Click
Dim a,ba , b as String
Dim x\mathbf { x } as Integer
a=\mathrm { a } = "How now brown cow."
b = "brown"
x=\mathbf { x } = FindIt (a,b)( \mathbf { a } , \mathbf { b } )
txtBox. Text =cStr(x)= \operatorname { cStr } ( x )
End Sub
Function FindIt(z1 as String, z2 as String) As Integer
Dim x\mathbf { x } as Integer
x=z1\mathbf { x } = \mathrm { z } 1 .IndexOf (z2)
End Function

A) "How now"
B) 8
C) 0
D) An error
E) None of the above
Question
The input to a user-defined function can consist of:

A) a single value
B) one or more values
C) no values
D) All of the above
Question
A user-defined function cannot be used in an expression.
Question
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 nam, result As Double
num =CDbl= \mathrm { CDbl } (InputBox ("Enter a number to cube:"))
result == Cube (nam)
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

A) 1 only
B) 2 only
C) Both 1 and 2
D) Neither 1 nor 2
Question
Which one of the following is true about arguments and parameters?

A) Arguments appear in calling statements; parameters appear in Sub statements.
B) Parameters appear in calling statements; arguments appear in Sub statements.
C) They are synonymous terms.
D) They are completely unrelated in a program.
Question
Both the input and output of a Function procedure can consist of several values.
Question
Function procedures can call other Function procedures.
Question
Each argument in a calling statement must have the same name as the corresponding parameter in the header of the called procedure.
Question
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 \&=a \& b
End Sub

A) ab ba
B) abba
C) ABBA
D) AB BA
Question
The ____________of a Sub procedure are vehicles for passing numbers and strings to the Sub procedure.

A) calling statements
B) arguments
C) parameters
D) variables declared inside
Question
Function procedures are different from Sub procedures because functions return a single value.
Question
Each parameter defined for a Sub procedure corresponds to an argument passed in a calling statement for that procedure.
Question
What will be the output of the following program when the button is clicked on? Private Sab btnDisplay_Click(...) Handles btnDisplay.Click
Dim num As Integer =10= 10
DisplayMult (num)
num =5= 5
DisplayMult (num)
num =2= 2
DisplayMult (num)
End Sub
Sub DisplayMalt (num As Integer)
If num <=3< = 3 Then
txtoutput. Text &=CStr(3\& = \operatorname { CStr } ( 3 \star num)
Else
If num >7> 7 Then
txtoutput. Text &=cst\&= \operatorname { cst } r (7 * num)
End If
End If
End Sub

A) 7014
B) 30614
C) 706
D) No output
Question
Both constants and expressions can be used as arguments in calling statements.
Question
Sub procedures can be called only once during the execution of a program.
Question
Which of the following is NOT a reason for using procedures?

A) They break a complex problem down into smaller pieces.
B) They make a program run faster.
C) They can be reused easily.
D) They make it easier for a team of people to work together on a single program.
Question
Items appearing in the parentheses of a calling statement are known as____________ .

A) call variables
B) call strings
C) parameters
D) arguments
Question
Parameters appearing in a Sub statement are part of the Sub procedure name.
Question
Arguments and parameters can be used to pass values to Sub procedures from event procedures or other Sub procedures.
Question
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 = "hai rbrush"
Decapitate (word)
txtBox. Text == word
End Sab

Sub Decapitate (ByRef word As String)
' Chop the first letter off the word.
word = word. Substring (1)
End Sab

A) airbrush
B) hairbrush
C) hairbrus
D) h
Question
A Sub procedure can call another Sub procedure.
Question
What keyword in the header of a sub procedure denotes that a variable is passed by reference?

A) AsRef
B) ByReference
C) ByRef
D) ByVal
Question
The process of transmitting values to a Sub procedure is known as____________ .

A) passing
B) conveying
C) evaluating
D) referencing
Question
What will be displayed when the button is clicked on? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dimx,y\operatorname { Dim } x , y As String
x=\mathbf { x } = "tin"
y=\mathrm { y } = "can"
Swap (x, y)
txtOutput. Text =x&""&y= x \& " "\&y
End Sub
Sub Swap (ByRef xx As String, y As String)
Dim temp As String
temp =x= \mathbf { x }
x=y\mathbf { x } = \mathbf { y }
y=\mathrm { y } = temp
End Sub

A) tin can
B) can tin
C) tin tin
D) can can
Question
10. 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

A) FirstSecondThird
B) ThirdSecondFirst
C) SecondThirdFirst
D) No output
Question
Suppose the variable myName is declared in a Dim statement in two different Sub procedures. Which statement is true?

A) The program will malfunction when it is executed.
B) When the value of myName is changed in one Sub procedure, it will also be changed in the other Sub procedure.
C) Visual Basic's smart editor will alert you that this is an error before the program is executed.
D) The two variables will be local to their respective Sub procedures.
Question
Both constants and expressions can be used as parameters in Sub statements.
Question
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 =
DoubleAndSquare (number)
txtBox. Text = CStr (number)
End Sub

Sub DoubleAndSquare (ByRef myVar As Double)
myVar = myVar + myVar
myVar = myVar * myVar
End Sab


A) 3
B) 36
C) 6
D) 0
Question
A value assigned to a variable in one part of a program always affects the value of the like- named variable in the other part of the program.
Question
Which of the following is NOT considered part of a good top-down design chart?

A) A module should accomplish as many tasks as possible.
B) Modules should proceed from general to specific as you read down the chart.
C) Modules should be as independent of each other as possible.
D) The design should be readable.
Question
When the button is clicked, the output of the following program will be 20.
Private Sab btnDisplay_Click (.( . . ) Handles btnDisplay.Click
Dim num As Integer =20= 20
DoubleIt (num)
txtBox.Text = CStr (num)
End Sub

Sub DoubleIt (ByRef var As Integer)
var = var 2\star 2
End Sub
Question
Stepwise refinement refers to

A) the process whereby a malfunctioning program is fixed by correcting one "bug" at a time.
B) any procedure that calls another procedure (and so on) to accomplish a task.
C) breaking a large task into smaller tasks.
D) the belief that increasing the number of people working on a project decreases the time it will take to complete the project.
Question
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?

A) It will have the newly modified value from inside the Sub procedure.
B) Its value can't be determined without more information.
C) It will retain the value it had before the call to the Sub procedure.
D) None of the above
Question
Variables and named constants declared inside a procedure are said to have____________ .

A) local scope
B) procedure-level scope
C) class-level scope
D) None of the above
Question
You can determine whether a variable is being passed by value or reference by looking at the calling statement.
Question
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?

A) It will have the newly modified value from inside the Sub procedure.
B) Its value can't be determined without more information.
C) It will retain the value it had before the call to the Sub procedure.
D) None of the above
Question
The declaration statement for a class-level variable should be placed____________ .

A) inside an event procedure
B) inside a general procedure
C) anywhere in the program region, except inside a procedure
D) above the statement Public Class frmName
Question
Sub procedures can be individually tested before being placed into a program.
Question
What will be the output of the following program when the button is clicked on? Private Sab btnDisplay_Click (..( . . . )HandlesbtnDisplay.Click) Handles btnDisplay.Click
Dim var1, var2, num As Integer
var1 =2= 2
var2 =4= 4
num =6= 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

A) 0
B) 12
C) 6
D) None of the above
Question
In modular programming, a driver is

A) another name for the team leader of a project.
B) a "dummy" program designed solely to call a single procedure and examine its returned values.
C) one of the event procedures that a user can invoke.
D) never to be used.
Question
What happens to a variable declared locally inside a Sub procedure after the procedure terminates?

A) It maintains its value even after the End Sub statement executes.
B) It ceases to exist after the End Sub statement executes.
C) It loses its value temporarily after the End Sub statement executes, but regains that value upon re-entry to the Sub procedure.
D) It is reset to its default value.
Question
Breaking up a large problem into smaller subproblems is called ____________.

A) transcribed refinement
B) refined modules
C) stepwise refinement
D) transcribed modules
Question
Each variable must be passed either by value or by reference.
Question
A variable or named constant that is visible to every procedure in a form's code without being passed is called a ____________ variable.

A) local
B) class-level
C) global
D) public
Question
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&= \operatorname { var } 1 \& \operatorname { var } 2 \& word 3
End Sub

A) TheEnglishChannel
B) TheEnglish
C) The English Channel
D) No output
Question
Top-down design refers to

A) an obsolete programming practice in which a program is written without procedures in one large module.
B) a program design where the key event procedures act like supervisors, delegating tasks to various Sub procedures.
C) a method of organizing a team of programmers.
D) a method of increasing the speed of a program.
Question
The value of an argument in a calling statement can be changed by a Sub procedure only if the same name is used in the Sub procedure's parameter list.
Question
One advantage to using top-down design in writing a program is that the program can later be modified with less of a chance of introducing new errors.
Question
Visual Basic 2012 is an object-oriented language.
Question
A(n)____________ is an encapsulation of data and code that operates on the data.

A) object
B) driver
C) decision
D) module
Question
Debugging an unstructured program often requires the programmer to look at the entire program in order to make even a simple modification.
Question
With top-down design, higher-level modules control the flow of the program while lower level modules do the actual work.
Question
A program is said to be____________ if it meets modern standards of program design.

A) top-down
B) logical
C) modular
D) structured
Question
Modular design decreases the programmer's productivity.
Question
Most modern programmers use a blend of traditional structured programming along with object-oriented design.
Question
"Stub programming" is one method of testing and debugging the key event procedures in a program.
Question
Studies have shown that despite the many benefits of structured programming, it usually takes a longer amount of time when used on large programming projects.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/70
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 5: General Procedures
1
A Function procedure may return up to two values.
False
2
Although a Function procedure can return a value, it cannot directly display information in a text box.
False
3
A Function procedure need not have parameters.
True
4
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)

A) It is not valid to pass something like "The Jetsons."
B) Constant values like 1000 cannot be passed, only variables.
C) var1 is not of the same data type as "The Jetsons."
D) Nothing is wrong with them.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
5
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

A) progr
B) r
C) e
D) progre
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
6
Function names should be suggestive of the role performed. The names also must conform to the rules for naming variables.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
7
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

A) FirstWord
B) LastWord
C) FirstLetter
D) LastLetter
E) DoesNothing
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
8
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

A) jaminBBenjaminen
B) BenjaminBenjamin
C) njaminBe
D) None of the above
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
9
The header of a Function procedure must include parameters.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
10
When the button is clicked on, the output of the following program will be 5.
Private Sab btnDisplay_Click(...) Handles btnDisplay.Click
Dim x,yx , y , result As Double
x=3\mathbf { x } = 3
y=4\mathrm { y } = 4
result =CInt((Norm(x,y)))= \operatorname { CInt } ( ( \operatorname { Norm } ( x , y ) ) )
txtBox. Text =cstr(= \operatorname { cstr } ( result ))
End Sub
Function Norm(x As Double, y As Double) As Double
Return Math.Sqrt x ^ 2 + y ^ 2
End Function
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
11
The value returned by a Function procedure must be a number or a string.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
12
The input to a user-defined function can consist of one or more values.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
13
Variables appearing inside the parentheses of a calling statement are called___________ .

A) values of the function
B) parameters
C) coordinates
D) arguments
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
14
What is displayed when the button is clicked on? Private Sab btnDisplay_Click(...) Handles btnDisplay.Click
Dim a,ba , b as String
Dim x\mathbf { x } as Integer
a=\mathrm { a } = "How now brown cow."
b = "brown"
x=\mathbf { x } = FindIt (a,b)( \mathbf { a } , \mathbf { b } )
txtBox. Text =cStr(x)= \operatorname { cStr } ( x )
End Sub
Function FindIt(z1 as String, z2 as String) As Integer
Dim x\mathbf { x } as Integer
x=z1\mathbf { x } = \mathrm { z } 1 .IndexOf (z2)
End Function

A) "How now"
B) 8
C) 0
D) An error
E) None of the above
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
15
The input to a user-defined function can consist of:

A) a single value
B) one or more values
C) no values
D) All of the above
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
16
A user-defined function cannot be used in an expression.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
17
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 nam, result As Double
num =CDbl= \mathrm { CDbl } (InputBox ("Enter a number to cube:"))
result == Cube (nam)
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

A) 1 only
B) 2 only
C) Both 1 and 2
D) Neither 1 nor 2
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
18
Which one of the following is true about arguments and parameters?

A) Arguments appear in calling statements; parameters appear in Sub statements.
B) Parameters appear in calling statements; arguments appear in Sub statements.
C) They are synonymous terms.
D) They are completely unrelated in a program.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
19
Both the input and output of a Function procedure can consist of several values.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
20
Function procedures can call other Function procedures.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
21
Each argument in a calling statement must have the same name as the corresponding parameter in the header of the called procedure.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
22
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 \&=a \& b
End Sub

A) ab ba
B) abba
C) ABBA
D) AB BA
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
23
The ____________of a Sub procedure are vehicles for passing numbers and strings to the Sub procedure.

A) calling statements
B) arguments
C) parameters
D) variables declared inside
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
24
Function procedures are different from Sub procedures because functions return a single value.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
25
Each parameter defined for a Sub procedure corresponds to an argument passed in a calling statement for that procedure.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
26
What will be the output of the following program when the button is clicked on? Private Sab btnDisplay_Click(...) Handles btnDisplay.Click
Dim num As Integer =10= 10
DisplayMult (num)
num =5= 5
DisplayMult (num)
num =2= 2
DisplayMult (num)
End Sub
Sub DisplayMalt (num As Integer)
If num <=3< = 3 Then
txtoutput. Text &=CStr(3\& = \operatorname { CStr } ( 3 \star num)
Else
If num >7> 7 Then
txtoutput. Text &=cst\&= \operatorname { cst } r (7 * num)
End If
End If
End Sub

A) 7014
B) 30614
C) 706
D) No output
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
27
Both constants and expressions can be used as arguments in calling statements.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
28
Sub procedures can be called only once during the execution of a program.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
29
Which of the following is NOT a reason for using procedures?

A) They break a complex problem down into smaller pieces.
B) They make a program run faster.
C) They can be reused easily.
D) They make it easier for a team of people to work together on a single program.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
30
Items appearing in the parentheses of a calling statement are known as____________ .

A) call variables
B) call strings
C) parameters
D) arguments
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
31
Parameters appearing in a Sub statement are part of the Sub procedure name.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
32
Arguments and parameters can be used to pass values to Sub procedures from event procedures or other Sub procedures.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
33
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 = "hai rbrush"
Decapitate (word)
txtBox. Text == word
End Sab

Sub Decapitate (ByRef word As String)
' Chop the first letter off the word.
word = word. Substring (1)
End Sab

A) airbrush
B) hairbrush
C) hairbrus
D) h
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
34
A Sub procedure can call another Sub procedure.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
35
What keyword in the header of a sub procedure denotes that a variable is passed by reference?

A) AsRef
B) ByReference
C) ByRef
D) ByVal
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
36
The process of transmitting values to a Sub procedure is known as____________ .

A) passing
B) conveying
C) evaluating
D) referencing
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
37
What will be displayed when the button is clicked on? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dimx,y\operatorname { Dim } x , y As String
x=\mathbf { x } = "tin"
y=\mathrm { y } = "can"
Swap (x, y)
txtOutput. Text =x&""&y= x \& " "\&y
End Sub
Sub Swap (ByRef xx As String, y As String)
Dim temp As String
temp =x= \mathbf { x }
x=y\mathbf { x } = \mathbf { y }
y=\mathrm { y } = temp
End Sub

A) tin can
B) can tin
C) tin tin
D) can can
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
38
10. 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

A) FirstSecondThird
B) ThirdSecondFirst
C) SecondThirdFirst
D) No output
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
39
Suppose the variable myName is declared in a Dim statement in two different Sub procedures. Which statement is true?

A) The program will malfunction when it is executed.
B) When the value of myName is changed in one Sub procedure, it will also be changed in the other Sub procedure.
C) Visual Basic's smart editor will alert you that this is an error before the program is executed.
D) The two variables will be local to their respective Sub procedures.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
40
Both constants and expressions can be used as parameters in Sub statements.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
41
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 =
DoubleAndSquare (number)
txtBox. Text = CStr (number)
End Sub

Sub DoubleAndSquare (ByRef myVar As Double)
myVar = myVar + myVar
myVar = myVar * myVar
End Sab


A) 3
B) 36
C) 6
D) 0
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
42
A value assigned to a variable in one part of a program always affects the value of the like- named variable in the other part of the program.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
43
Which of the following is NOT considered part of a good top-down design chart?

A) A module should accomplish as many tasks as possible.
B) Modules should proceed from general to specific as you read down the chart.
C) Modules should be as independent of each other as possible.
D) The design should be readable.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
44
When the button is clicked, the output of the following program will be 20.
Private Sab btnDisplay_Click (.( . . ) Handles btnDisplay.Click
Dim num As Integer =20= 20
DoubleIt (num)
txtBox.Text = CStr (num)
End Sub

Sub DoubleIt (ByRef var As Integer)
var = var 2\star 2
End Sub
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
45
Stepwise refinement refers to

A) the process whereby a malfunctioning program is fixed by correcting one "bug" at a time.
B) any procedure that calls another procedure (and so on) to accomplish a task.
C) breaking a large task into smaller tasks.
D) the belief that increasing the number of people working on a project decreases the time it will take to complete the project.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
46
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?

A) It will have the newly modified value from inside the Sub procedure.
B) Its value can't be determined without more information.
C) It will retain the value it had before the call to the Sub procedure.
D) None of the above
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
47
Variables and named constants declared inside a procedure are said to have____________ .

A) local scope
B) procedure-level scope
C) class-level scope
D) None of the above
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
48
You can determine whether a variable is being passed by value or reference by looking at the calling statement.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
49
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?

A) It will have the newly modified value from inside the Sub procedure.
B) Its value can't be determined without more information.
C) It will retain the value it had before the call to the Sub procedure.
D) None of the above
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
50
The declaration statement for a class-level variable should be placed____________ .

A) inside an event procedure
B) inside a general procedure
C) anywhere in the program region, except inside a procedure
D) above the statement Public Class frmName
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
51
Sub procedures can be individually tested before being placed into a program.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
52
What will be the output of the following program when the button is clicked on? Private Sab btnDisplay_Click (..( . . . )HandlesbtnDisplay.Click) Handles btnDisplay.Click
Dim var1, var2, num As Integer
var1 =2= 2
var2 =4= 4
num =6= 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

A) 0
B) 12
C) 6
D) None of the above
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
53
In modular programming, a driver is

A) another name for the team leader of a project.
B) a "dummy" program designed solely to call a single procedure and examine its returned values.
C) one of the event procedures that a user can invoke.
D) never to be used.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
54
What happens to a variable declared locally inside a Sub procedure after the procedure terminates?

A) It maintains its value even after the End Sub statement executes.
B) It ceases to exist after the End Sub statement executes.
C) It loses its value temporarily after the End Sub statement executes, but regains that value upon re-entry to the Sub procedure.
D) It is reset to its default value.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
55
Breaking up a large problem into smaller subproblems is called ____________.

A) transcribed refinement
B) refined modules
C) stepwise refinement
D) transcribed modules
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
56
Each variable must be passed either by value or by reference.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
57
A variable or named constant that is visible to every procedure in a form's code without being passed is called a ____________ variable.

A) local
B) class-level
C) global
D) public
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
58
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&= \operatorname { var } 1 \& \operatorname { var } 2 \& word 3
End Sub

A) TheEnglishChannel
B) TheEnglish
C) The English Channel
D) No output
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
59
Top-down design refers to

A) an obsolete programming practice in which a program is written without procedures in one large module.
B) a program design where the key event procedures act like supervisors, delegating tasks to various Sub procedures.
C) a method of organizing a team of programmers.
D) a method of increasing the speed of a program.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
60
The value of an argument in a calling statement can be changed by a Sub procedure only if the same name is used in the Sub procedure's parameter list.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
61
One advantage to using top-down design in writing a program is that the program can later be modified with less of a chance of introducing new errors.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
62
Visual Basic 2012 is an object-oriented language.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
63
A(n)____________ is an encapsulation of data and code that operates on the data.

A) object
B) driver
C) decision
D) module
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
64
Debugging an unstructured program often requires the programmer to look at the entire program in order to make even a simple modification.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
65
With top-down design, higher-level modules control the flow of the program while lower level modules do the actual work.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
66
A program is said to be____________ if it meets modern standards of program design.

A) top-down
B) logical
C) modular
D) structured
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
67
Modular design decreases the programmer's productivity.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
68
Most modern programmers use a blend of traditional structured programming along with object-oriented design.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
69
"Stub programming" is one method of testing and debugging the key event procedures in a program.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
70
Studies have shown that despite the many benefits of structured programming, it usually takes a longer amount of time when used on large programming projects.
Unlock Deck
Unlock for access to all 70 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 70 flashcards in this deck.