Quiz 4-Sections 3.4 and 3.5-October 8 Section 3.4 Strings 1. What is the correct syntax for displaying the value of the String variable myString in a text box? (A) (B) (C) (D) 2. Which statement will assign the words “Hello World” to a text box? (A) (B) (C) (D) 3. = = = = Hello & World "Hello " & World Hello & " World" "Hello" & " World" txtBox.Empty = True txtBox = "" txtBox.Text = "" txtBox.Wipe() What character is used to signify the beginning of a comment statement? (A) (B) (C) (D) 5. txtBox.Text txtBox.Text txtBox.Text txtBox.Text Which statement can be used to clear the contents of a text box? (A) (B) (C) (D) 4. txtBox.Text = "myString" txtBox.Text = myString txtBox.Text.myString txtBox.Text = Str(myString) asterisk exclamation mark apostrophe backslash The joining of two strings together to form a new string is called (A) (B) (C) (D) concatenation. addition. compaction. substrings. 6. 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) (A) (B) (C) (D) 7. abcdeABCDE ABCDEABCDE eE EE To continue a long statement on another line, use (A) (B) (C) (D) an underscore character. an ampersand character. Ctrl + Enter. a space followed by an underscore character. Section 3.5 Input and Output 1. Which format statement should be used when you want to output your results in tabular format with the first column 10 characters wide, the second 5, and the third 10? (A) (B) (C) (D) Dim Dim Dim Dim fmtStr fmtStr fmtStr fmtStr as as as as String String String String = = = = "{10}{5}{10}" "{0}{1}{2}" "{0, 10}{1, 5}{2, 10}" "{0, 10; 1, 5; 2, 10}" 2. Which declaration statement is used when you want to read data from the file DATA.TXT? (A) (B) (C) (D) 3. Dim Dim Dim Dim sr As IO.StreamReader = IO.File.OpenText("DATA.TXT") sr As IO.StreamReader = IO.File.OpenText(DATA.TXT) DATA.TXT As IO.File.OpenText IO.File.OpenText("DATA.TXT") Suppose the first two lines of the file DATA.TXT contain the strings Clint and 1930. What is displayed by the following lines of code? Dim name As String, birthYear As Integer Dim sr As IO.StreamReader = IO.File.OpenText("DATA.TXT") name = sr.ReadLine birthYear = CInt(sr.ReadLine) txtBox.Text = "In 2005, " & name & " will be " & (2005 – birthYear) sr.Close() (A) (B) (C) (D) 4. Clint, 1930 In 2005, Clint will be 2005 – 1930 In 2005, "Clint" will be 75 In 2005, Clint will be 75 What will be displayed when the following lines are executed? Dim x As Double = 2 Dim y As Double = 3 Dim fmtStr As String = "{0,-5}{1, -5}" lstOutput.Items.Add("1234567890") lstOutput.Items.Add(String.Format(fmtStr, x, y)) (A) 1234567890 23 (B) 1234567890 2 3 (C) 1234567890 2 3 (D) 1234567890 2 3 5. If sr is a StreamReader, then a statement of the form var = sr.ReadLine reads an item of data from a file and assigns it to the string variable var. (T/F) 6. Write a statement that assigns the first character of the value of strVar1 to strVar2.