Intro To Cs Second Quarterly

12 Questions | Total Attempts: 72  Settings  • 1.
Consider a form that has a text box called txtName, a check box called chkMale, a button, and a label called lblAddr. Assume text box also contains the first and last name of a person. Write the code for the button that does the following. Writes into the label the first initial  followed by the last name. If the check box is checked, the name displayed in the label is preceded by "Mr.", otherwise it is preceded by "Ms."  For example, if the check box is checked, and the text box contains "Pete Seeger", the label should contain "Mr. P Seeger". If the check box is not checked and the text box contains "Joan Baez", the label should contain "Ms. J Baez".
• 2.
Consider the String variable strSchool which equals "Middletown South". What is the difference between the expression strSchool.substring(3,6) and strSchool.remove(3, 6)?
• 3.
Consider three variables intAmount, dblCost, and dblShipping, which contain the number of items purchased, the cost of each item, and the shipping charge. Write the code that calculates the total cost of the order. Keep in mind that if the cost of each item is over 100 dollars or the customer orders at least 10 items, shipping is free.
• 4.
I'm writing a password generator. Among the changes I will make to the input string is to change all instances of the letter 'o' to the digit zero. Which String function would I use?
• A.

Substring

• B.

• C.

Replace

• D.

Insert

• 5.
I want my if statement to be true it my variable intAge is between 18 and 65, inclusive. Does the following if statement work? If 18 <= intAge OR intAge <= 65Then
• A.

Yes

• B.

No

• 6.
Consider the following code Dim guitar as String = "Bruce Springsteen" What is returned from the following statement: guitar.StartsWith("bu")
• A.

True

• B.

False

• 7.
What does the the following line of code do? Dim bar as String = "United States" Dim foo as String = bar.substring(bar.length() - 1, 1)
• A.

Crashes

• B.

Copies the last character in United States into the variable foo

• C.

Copies the first character in United States into the variable foo

• D.

Its a syntax error

• E.

Baraksan

• 8.
Are the following if statements equivalent (Do they produce true and false under the same conditions?) 1) If intTemp > 98.6 Then ... 2) If Not Temp <= 98.6 Then ...
• A.

Yes

• B.

No

• 9.
Consider the following subroutine Public Sub MakeLabel(ByVal toggle as Boolean, ByVal Name as String,  ByVal n as Integer)         Dim strF as String = name.substring(0, n);         Dim strB as String = name.remove(0, n);         if toggle then            lblOutput.txt = strF.upper() & strB.ToLower()        else             lblOutput.text = strfF.lower() & strB.ToUpper()       endIf End Sub If I run the following statement MakeLabel(True, "January", 4) What is written in the lblOutput label?
• 10.
The function ToUpper() converts a string to upper case.
• A.

True

• B.

False

• 11.
Consider the following declaration:Dim foobar as String = "bookkeeper"What is the value of foobar after the following statement?foobar = foobar.replace("bo", "zo")
• 12.
Consider the following declaration:Dim str as String = "success"What is the value of str after the following statement?str = str.Trim("s")
Related Topics Back to top