BUS 442- Final Exam

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

An event procedure is a Sub procedure that is associated with a specific object and event.

True

If the restaurant variable contains the string "The Bistro", what will the restaurant.ToUpper.Contains("BISTRO") method return? a. 4 b. 5 c. True d. False

True

Explain the difference between a Sub procedure and a function.

Unlike a Sub procedure, a function returns a value after completing its assigned task.

Explain the difference between passing a variable by value and passing it by reference.

When you pass a variable by value, you are passing only a copy of the variable's contents; the receiving procedure cannot access the variable and, therefore, it cannot change the variable's contents. To pass a variable by value, you include the keyword ByVal before the name of its corresponding parameter in the receiving procedure's header. When you pass a variable by reference, you are passing the address of the variable in the computer's internal memory; the receiving procedure can access the variable and can change its contents. To pass a variable by reference, you include the keyword ByRef before the name of its corresponding parameter in the receiving procedure's header.

Explain the difference between invoking a Sub procedure and invoking a function.

You can use the Call statement to invoke a Sub procedure. Or, you can simply enter the Sub procedure's name on a separate line in the code. You invoke a function by including the function's name and arguments (if any) in a statement, such as in an assignment statement.

Which of the following statements creates an array that contains three rows and four columns? a. Dim temps (2,3) As Decimal a. Dim temps (3,4) As Decimal a. Dim temps (3,2) As Decimal a. Dim temps (4,3) As Decimal

a. Dim temps (2,3) As Decimal

Which of the following concatenates the contents of the city variable, 10 spaces, and the contents of the state variable, and then assigns the result to the address variable? a. address = city & Space(10) & state b. address = city & Spaces(10) & state c. address = city & Strings.Space(10) & state d. address = city & String.Space(10) & state

address = city & Strings.Space(10) & state

Which of the following assigns the string "Maple" to the street member variable within a structure variable named address? a. address&street = "Maple" b. address.street = "Maple" c. street.address = "Maple" d. none of the above

address.street = "Maple"

Which of the following changes the contents of the grade variable from A to A++++? a. grade = grade.Insert(1, "++").PadRight(5,"+"c) b. grade = grade.PadRight(5, "+"c) c. grade = grade.Insert (1, "++++") d. all of the above

all of the above

Which of the following changes the contents of the zip variable from 60121 to 60321? a. zip = zip.Remove(2,1) zip = zip.Insert(2,"3") b. zip = zip.Remove(2,"3") zip = zip.Insert(3,1) c. zip = zip.Remove(2,1).Insert(2,"3") d. all of the above

all of the above

Which of the following declares a four-row, two-column String array named letters? a. Dim letters (3,1) As String b. Private letters (3,1) As String c. Dim letters (,) As String = {{"A", "B"},{"C","D"}, {"E","F"},{"G","H"}} d. all of the above

all of the above

Use the following information: Dim numbers() As Double = {10, 5, 7, 2} Dim x As Integer Dim total As Double Dim avg As Double Which of the following will correctly calculate the average of the elements included in the numbers array? a. Do While x < numbers.Length numbers(x) = total + total x += 1 Loop avg = total/x b. Do While x < numbers.Length total += numbers(x) x += 1 Loop avg = total/x c. Do While x < numbers.Length total += numbers(x) x += 1 Loop avg = total/x -1 d. Do While x < numbers.Length total += numbers(x) x += 1 Loop avg = total/(x-1)

b. Do While x < numbers.Length total += numbers(x) x += 1 Loop avg = total/x

Which of the following changes the content of the amount variable from 76.89 to 76.89!!!! ? a. amount= amount.PadRight(4, "!"c) b. amount = amount.PadRight(9, "!"c) c. amount = amount.PadLeft(4, "!"c) d. none of the above

b. amount = amount.PadRight(9, "!"c) (9, "!"c) 9 = total length of string "!"c = character ! for any empty spots

Which of the following assigns the sixth character in the word variable to the letter variable? a. letter = word.Substring(4,1) b. letter = word.Substring(5,1) c. letter = word.Substring(5) d. none of the above

b. letter = word.Substring(5,1)

Which of the following changes the contents of the product variable from Shirts to Shirt? a. product = product.Remove(5, "s") b. product = product.Remove(5) c. product = product.Remove(6,"s") d. product = product.Remove("s")

b. product = product.Remove(5)

A procedure needs to write information to a sequential access file. Which of the following methods can be used to open the file? a. AppendText b. CreateText c. OpenText d. both a and b

both a and b

Which of the following assigns the number of elements contained in a one-dimensional array named items to the numElements variable? a. numElements = items.Length b. numElements = items.GetUpperBound(0) + 1 c. numElements = items.GetNumItems(0) d. both a and b

both a and b

Which of the following declares a Vehicle variable named car? a. Private car As Vehicle b. Dim car As Vehicle c. Dim Vehicle as car d. both a and b

both a and b

Which of the following declares a five-element array named prices? a. Dim prices(4) As Decimal b. Dim prices(5) As Decimal c. Dim prices() As Decimal = {3.55D, 6.7D, 8D, 4D, 2.34D} d. both a and c

both a and c

Which of the following If clause verifies that the array subscript stored in the x variable is valid for the sales array? a. If sales(x) >= 0 AndAlso sales(x) < 4 Then b. If sales(x) >= 0 OrElse sales(x) <= 4 Then c. If x >= 0 AndAlso x <=sales.GetUpperBound(0) Then d. If x >= 0 AndAlso x <sales.GetUpperBound(0) Then

c. If x >= 0 AndAlso x <=sales.GetUpperBound(0) Then

Which of the following is false? a. Menu titles should be one word only. b. Each menu title should have a unique access key. c. You should assign shortcut keys to commonly used menu titles d. Menu items should be entered using book title capitalization.

c. You should assign shortcut keys to commonly used menu titles

Which of the following assigns the first three characters in the partNum variable to the code variable? a. code = partNum.Assign(0,3) b. code = partNum.Sub(0,3) c. code = partNum.Substring(0,3) d. code = partNum.Substring(1,3)

c. code = partNum.Substring(0,3)

If the msg variable contains the string "Tomorrow is Friday", which of the following returns the number 12? a. msg.Substring(0,"F") b. msg.Contains("F") c. msg.IndexOf("F") d. msg.IndexOf(0, "F")

c. msg.IndexOf("F")

Which of the following expressions evaluates to True when the partNum variable contains ABC73? a. partNum like "[A-Z]99" b. partNum like "[A-Z]##" c. partNum like "[A-Z][A-Z][A-Z]##" d. none of the above

c. partNum like "[A-Z][A-Z][A-Z]##"

Which of the following allows you to access a menu item without opening the menu? a. an access key b. a menu key c. shortcut keys d. none of the above

c. shortcut keys

Which of the following assigns the string "California" to the variable located in the 3rd column, 5th row of the states array? a. states(3,5) = "California" b. states(5,3) = "California" c. states (4,2) = "California" d. states (2,4) = "California"

c. states (4,2) = "California"

Which of the following assigns the string "Jaguar" to the maker member of a Vehicle variable named car? a. car.maker = "Jaguar" b. Vehicle.maker = "Jaguar" c. Vehicle.car.maker = "Jaguar" d. maker.car = "Jaguar"

car.maker = "Jaguar"

Which of the following assigns the string "Scottsburg" to the fifth element in a one-dimensional array named cities? a. cities(4) = "Scottsburg" b. cities(5) = "Scottsburg" c. cities[4] = "Scottsburg" d. cities[5] = "Scottsburg"

cities(4) = "Scottsburg"

Which of the following converts the sender parameter to the Label data type, assigning the result to a Label variable named currentLabel? a. TryCast(sender, Label, currentLabel) b. currentLabel = TryCast(sender, Label) c. currentLabel = TryCast(Label, sender) d. sender = TryCast (currentLabel, Label)

currentLabel = TryCast (sender, Label)

A sequential access file contains records whose fields are separated by a dollar sign. Which of the following reads a record from the file and assigns the fields to the customer array? a. customer = inFile.ReadLine.Split($) b. customer = inFile.ReadLine.Split("$"c) c. customer = inFile.Split("$") d. customer = inFile.Split.ReadLine ("$"c)

customer = inFile.ReadLine.Split("$"c)

Use the following information: Dim sales(,) As Decimal = {{1000, 1200, 900, 500, 2000}, {350, 600, 700, 800, 100}} The sales (1,3) +=10 statement will replace the number ______. a. 900 with 910 b. 500 with 510 c. 700 with 710 d. 800 with 810

d. 800 with 810

Which of the following will correctly add 100 to each element in the sales array? The x variable was declared using the Dim x As Integer statement. a. Do While x <= sales.GetUpperBound(0) x += 100 Loop b. Do While x <= sales.GetUpperBound(0) sales += 100 Loop c. Do While sales < sales.Length sales(x) += 100 Loop d. Do While x < sales.Length sales(x) += 100 x += 1 Loop

d. Do While x < sales.Length sales(x) += 100 x += 1 Loop

The items array is declared using the Dim items(20) As String statement. The x variable keeps track of the array subscripts and is initialized to 0. Which of the following Do clauses will process the loop instructions for each element in the array? a. Do While x > items.GetUpperBound(0) b. Do While x < items.GetUpperBound c. Do While x >= items.GetUpperBound(0) d. Do While x <= items.GetUpperBound(0)

d. Do While x <= items.GetUpperBound(0)

Use the following information: Dim sales(,) As Decimal = {{1000, 1200, 900, 500, 2000}, {350, 600, 700, 800, 100}} Which of the following If clauses verifies that the array subscripts stored in the r and c variables are valid for the sales array? a. If sales(r, c) >= 0 AndAlso sales(r, c) <= sales.UpperBound(0) Then b. If sales(r, c) >= 0 AndAlso sales(r, c) <= sales.Length Then c. If r>=0 AndAlso r<sales.Length AndAlso c>= 0 AndAlso c<=sales.Length Then d. If r>=0 AndAlso r<=sales.GetUpperBound(0) AndAlso c>= 0 AndAlso c<=sales.GetUpperBound(1) Then

d. If r>=0 AndAlso r<=sales.GetUpperBound(0) AndAlso c>= 0 AndAlso c<=sales.GetUpperBound(1) Then

Which of the following determines whether the userEntry variable contains a dollar sign? a. userEntry.Contains("$") b. userEntry.IndexOf("$") c. userEntry.IndexOf("$",0) d. all of the above

d. all of the above

When entered in the FormClosing event procedure, which of the following prevents the computer from closing the form? a. e.Cancel = True b. e.Close = False c. e.Closing = False d. e.Open = True

e.Cancel = True

If the restaurant variable contains the string "Maria's Italian Deli", which of the following assigns the string "Italian" to the foodType variable? a. foodType = restaurant.Substring(8) b. foodType = restaurant.Substring(8,7) c. foodType = restaurant.Substring(9,7) d. both a and b

footType = restaurant.Substring(8,7) (8,7) 8 = Index position (include space) 7 = string length

An application uses a two-dimensional array named population. Which of the following assigns the array's highest column subscript to the highCol variable? a. highCol = population.GetUpperBound(0) a. highCol = population.GetUpperBound(1) a. highCol = population.GetUpperColumn(0) a. highCol = population.UpperColumn(1)

highCol = population.GetUpperBound(1)

Write the statement to close the sequential access file associated with the inFile variable.

inFile.Close()

An array is declared using the statement Dim inventory(4) As Product. Which of the following assigns the number 100 to the quantity member variable contained in the last array element? a. inventory.quantity(4) = 100 b. inventory(4).Product.quantity = 100 c. inventory(3).quantity = 100 d. inventory(4).quantity = 100

inventory(4).quantity = 100

Which of the following reads a line of text from the sequential access file associated with the inFile variable and assigns the line of text (excluding the newline character) to the msg variable? a. msg = inFile.Read b. msg = inFile.ReadLine c. inFile.ReadLine(msg) d. none of the above

msg = inFile.ReadLine

Which of the following assigns the number of characters stored in the msgLabel to the numChars variable?

numChars = msgLabel.Text.Length

A function can return ___________.

one value only

Write the statement to close the sequential access file associated with the outFile variable.

outFile.Close()

Which of the following writes the contents of the cityTextBox's Text property, followed by the newline character, to the sequential access file associated with the outFile variable? a. outFile.Write(cityTextBox.Text) b. outFile.WriteLine(cityTextBox.Text) c. outFile.WriteNext(cityTextBox.Text) d. none of the above

outFile.WriteLine(cityTextBox.Text)

Which of the following evaluates to True when the partNum variable contains the string "123X45"? a. partNum Like "999[A-Z]99" b. partNum Like "#####" c. partNum like "###[A-Z]##" d. partNum like "*[A-Z]"

partNum Like "###[A-Z]##"

Which of the following determine whether a percent sign (%) appears as the last character in the rateTextBox's Text property?

rateTextBox.Text Like "*%" *X = at the end of

Which of the following determines whether a comma appears anywhere in the salesTextBox's Text property? a. salesTextBox.Text Like "," b. salesTextBox.Text Like "*,*" c. salesTextBox.Text Like "[*,*]" d. none of the above

salesTextBox.Text Like "*,*" *X* = anywhere in between

Which of the following changes the contents of the state variable from Dakota to South Dakota? a. state = state.Insert(0, "South") b. state = state.Insert(1, "South") c. state = state.Insert("South", 0) d. state = state.Insert ("South", 1)

state = state.Insert(0, "South")

Which of the following changes the contents of the state variable from Kentucky to Ky? a. state = state.Remove(1,5) b. state = state.Remove(1,6) c. state = state.Remove(0,6) d. state = state.Remove(2,6)

state = state.Remove(1,6)

The state variable contains the letters K and Y followed by two spaces. Which of the following assigns only the letters K and Y to the variable? a. state = state.Trim b. state = Trim(state) c. state = Trim(state,"") d. state = Trim(2,2)

state = state.Trim

Each structure variable in the states array contains a String member named id and an Integer member named population. Which of the following assigns the string "RI" to the first element in the array? a. states(0).id = "RI" b. states(1).id = "RI" c. states.id(0) = "RI" d. states.id(1) = "RI"

states(0).id = "RI"

If the msg variable contains the string "Happy New Year", what value will the msg.IndexOf("Year") method return? a. -1 b. True c. 10 d. 11

10

Use the following information: Dim sales() As Integer = {10000, 12000, 900, 500, 20000} The sales(4) = sales(4-2) statement will replace the number _______.

20000 with 900

If the restaurant variable contains the string "The Bistro", what will the restaurant.ToUpper.IndexOf("BISTRO") method return? a. 4 b. 5 c. True d. False

4

Use the following information: Dim sales() As Integer = {10000, 12000, 900, 500, 20000} The sales(3) += 10 statement will replace the number ________.

500 with 510

Which of the following statements should you use to call the CalcEnd procedure described in Review Question 9? a. Call CalcEnd (begin, sales, purchases, ending) b. Call CalcEnd (ByVal begin, ByVal sales, ByVal purchases, ByRef ending) c. Call CalcEnd (ByRef begin, ByRef sales, ByRef purchases, ByRef ending) d. Call CalcEnd (ByVal begin, ByVal sales, ByVal purchases, ByVal ending)

A. Call CalcEnd (begin, sales, purchases, ending)

Which of the following assigns the Boolean value True to the element located in the third row, first column of a two-dimensional Boolean array named testAnswers? a. testAnswers (0,2) = True b. testAnswers (2,0) = True c. testAnswers (3,1) = True d. testAnswers(1,3) = True

testAnswers(2,0) = True

What does the Peek method return when a sequential access file contains another character to read?

the character

To determine whether a variable is being passed to a procedure by value or by reference, you will need to examine ______________.

the procedure header

A Sub procedure named CalcEnd is passed four Integer variables named begin, sales, purchase, and ending. The procedure should calculate the ending inventory using the beginning inventory, sales, and purchase amounts passed to the procedure. The result should be stored in the ending variable. Which of the following procedure headers is correct? A. Private Sub CalcEnd (ByVal b As Integer, ByVal s As Integer, ByVal p As Integer, ByRef final As Integer) B. Private Sub CalcEnd (ByVal b As Integer, ByVal s As Integer, ByVal p As Integer, ByVal final As Integer) C. Private Sub CalcEnd (ByRef b As Integer, ByRef s As Integer, ByRef p As Integer, ByVal final As Integer) D. Private Sub CalcEnd (ByRef b As Integer, ByRef s As Integer, ByRef p As Integer, ByRef final As Integer)

A. Private Sub CalcEnd (ByVal b As Integer, ByVal s As Integer, ByVal p As Integer, ByRef final As Integer)

Write the code to sort the scores array in ascending order.

Array.Sort(scores)

Which of the following is false? A. When you pass a variable by reference, the receiving procedure can change its contents. B. To pass a variable by reference in Visual Basic, you include the keyword ByRef before the variable's name in the Call statement. C. When you a pass a variable by value, the receiving procedure creates a procedure-level variable that it uses to store the value passed to it. D. At times, a computer memory location may have more than one name.

B. To pass a variable by reference in Visual Basic, you include the keyword ByRef before the variable's name in the Call statement.

Which of the following is false? a. The position of the arguments listed in the Call statement should agree with the position of the parameters listed in the receiving procedure's parameterList. b. The data type of each argument in the Call statement should match the data type of its corresponding parameter in the receiving procedure's parameterList. c. The name of each argument in the Call statement should be identical to the name of its corresponding parameter in the receiving procedure's parameterList. d. When you pass items of data to a procedure by value, the procedure stores the value of each item it receives in a separate memory location.

C. The name of each argument in the Call statement should be identical to the name of its corresponding parameter in the receiving procedure's parameterList

Which of the following invokes the Calc procedure from Question 2, passing it an Integer variable named sales and a Double variable named bonus? a. Call Calc(ByVal sales, ByRef bonus) b. Call Calc(sales, bonus) c. Call Calc(bonus, sales) d. both b and c

Call Calc(sales, bonus)

Which of the following invokes the CalcArea Sub procedure, passing it two variables by value? a. Call CalcArea (length, width) b. Call CalcArea (ByVal length, ByVal width) c. Invoke CalArea ByVal (length, width) d. CalcArea (length, width) As Double

Call CalcArea (length, width)

Which of the following invokes the DisplayMessage procedure from Question 2?

Call DisplayMessage()

In most applications, the Structure statement is entered in the form's ______.

Declarations section

Which of the following declares a four-element, one-dimensional String array named letters? a. Dim letters(3) As String b. Dim letters() As String = "A", "B", "C", "D" c. Dim letters(3) As String = {"A", "B", "C", "D"} d. all of the above

Dim letters(3) As String

Rewrite using a Do...Loop statement: For Each scoreElement In scores total += scoreElement Next scoreElement

Dim subscript As Integer Do While subscript <= 4 total += scores(subscript) subscript +=1 Loop

An application uses a structure named Employee. Which of the following statements creates a five-element array of Employee structure variables? a. Dim workers As Employee(4) b. Dim workers As Employee(5) c. Dim workers (4) As Employee d. Dim workers (5) As Employee

Dim workers (4) As Employee

To turn on a timer, you set its ____________ property to True.

Enabled

The scores array is a five-element Integer array. Which of the following will total the array values?

For Each scoreElement In scores total += scoreElement Next scoreElement

Rewrite using a For...Next statement.: For Each scoreElement In scores total += scoreElement Next scoreElement

For subscript As Integer = 0 to 4 total += scores(subscript) Next subscript

Which of the following associates a procedure with the TextChanged events of the nameTextBox and salesTextBox? a. Handles nameTextBox_TextChanged, salesTextBox_TextChanged b. Handles nameTextBox.TextChanged AndAlso salesTextBox.TextChanged c. Handles nameTextBox-TextChanged, salesTextBox-TextChanged d. Handles nameTextBox.TextChanged, salesTextBox.TextChanged

Handles nameTextBox.TextChanged, salesTextBox.TextChanged

A procedure needs to read information from a sequential access file. Which of the following methods can be used to open the file? a. AppendText b. CreateText c. OpenText d. both b and c

OpenText

Which of the following headers indicates that the procedure returns a Decimal number? a. Private Function Calc() As Decimal b. Private Sub Calc() As Decimal c. Private Function Calc(Decimal) d. both a and b

Private Function Calc() As Decimal

Which of the following indicates that the procedure will receive two items of data: an integer and the address of a Double variable? a. Private Sub Calc(ByVal x As Integer, ByRef y As Double) b. Private Sub Calc(Value x As Integer, Address y As Double) c. Private Sub Calc(ByInt x As Integer, ByAdd y As Double) d. Private Sub Calc(ByCopy x As Integer, ByAdd y As Double)

Private Sub Calc(ByVal x As Integer, ByRef y As Double)

Which of the following is a valid header for a procedure that receives the value stored in an Integer variable first, and the address of a Decimal variable second? a. Private Sub CalcFee(ByVal base As Integer, ByAdd rate As Decimal) b. Private Sub CalcFee (base As Integer, rate As Decimal) c. Private Sub CalcFee (ByVal base As Integer, ByRef rate as Decimal) d. none of the above

Private Sub CalcFee (ByVal base As Integer, ByRef rate As Decimal)

Which of the following is a valid header for a procedure that receives an integer followed by a number with a decimal place? a. Private Sub CalcFee(base As Integer, rate As Number) b. Private Sub CalcFee(ByRef base As Integer, ByRef rate As Decimal) c. Private Sub CalcFee(ByVal base As Integer, ByVal rate as Decimal) d. none of the above

Private Sub CalcFree (ByVal base As Integer, ByVal rate As Decimal)

Which of the following indicates that the procedure should be processed when the user clicks either the firstCheckBox or the secondCheckBox? a. Private SubClear(sender As Object, e As EventArgs) Handles firstCheckBox.Click, secondCheckBox.Click b. Private Sub Clear(sender As Object, e As EventArgs) Handles firstCheckBox_Click, secondCheckBox_Click c. Private Sub Clear_Click(sender As Object, e As EventArgs) Handles firstCheckBox, secondCheckBox d. Private Sub Clear(sender As Object, e As EventsArgs) Handles firstCheckBox.Click AndAlso secondCheckBox.Click

Private Sub Clear(sender As Object, e As EventsArgs) Handles firstCheckBox.Click, secondCheckBox.Click

Which of the following indicates that the procedure receives a copy of the values store in two String variables? a.Private Sub Display (ByRef x As String, ByRef y As String) b. Private Sub Display(ByVal x As String, ByVal y As String) c.Private Sub Display (ByValue x As String, ByValue y As String) d. Private Sub Display(ByCopy x As String, ByCopy y As String)

Private Sub Display(ByVal x As String, ByVal y as String)

Which of the following is the correct way to write a procedure header that does not require a parameterList? a. Private Sub DisplayMessage b. Private Sub DisplayMessage() c. Private Sub DisplayMessage(none) d. Private Sub DisplayMessage []

Private Sub DisplayMessage()

Which of the following instructs a function to return the contents of the stateTax variable? a. Return stateTax b. Return stateTax By Val c. Return ByVal stateTax d. Return ByRef stateTax

Return stateTax


Kaugnay na mga set ng pag-aaral

AAA ( Authentication, Authorization, Accounting )

View Set

geometric probability assignment

View Set

chpt 17 process cost systems (IN-CLASS)

View Set

SG Lewis Ch 56 Acute Intracranial Problems

View Set

Chapter 18: Management: Making it Work

View Set

4 Ventricles and Cerebrospinal Fluid

View Set

FA 1 - The Accounting Principles

View Set

health-premature death, heart disease, cancer, etc

View Set