Chapter 8 Text Files.pdf - Chapter 8 Text Files Section 8.1...

Info icon This preview shows pages 1–4. Sign up to view the full content.

Chapter 8: Text Files Section 8.1 Managing Text Files 1. What method is used to copy the contents of a string array or LINQ query into a text file? (A) CreateTextFile (B) WriteAllLines (C) CopyToTextFile (D) ReadAllLines Answer is B 2. Which of the following methods is used to change the words in a column header of a DataGridView control? (A) HeaderText (B) HeaderName (C) HeaderContent (D) HeaderCaption Answer is A 3. What property is set to False in order to remove the row header column on the left side of a DataGridView control? (A) ShowRowHeader (B) DisplayRowHeader (C) RowHeaderVisible (D) RowHeaderEnabled Answer is C 4. A statement of the form IO.File.WriteAllLines("fileName.txt", numArray) copies the contents of the numeric array numArray into a text file. (T/F) Answer is F 5. The acronym CSV stands for "Comma Separated Values". (T/F) Answer is T
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

6. Each record of the file UN.txt contains four pieces of information (name, continent, population in millions, area) about one of the 192 member countries of the United Nations. The first two lines of the file are Afghanistan,Asia,28.2,251772 Albania,Europe,3.2,11100 What is the first line of the file created by the following code? Dim query = From line In IO.File.ReadAllLines("UN.txt") Let data = line.Split(","c) Let country = data(0) Let continent = data(1) Select country & " is in " & continent IO.File.WriteAllLines("NewFile.txt", query) (A) Afghanistan is in Asia (B) Albania is in Europe (C) country is in continent (D) The new file will be empty. Answer is A 7. Each line of the file UN.txt contains four pieces of information (name, continent, population in millions, area) about one of the 192 member countries of the United Nations. The first two lines of the file are Afghanistan,Asia,28.2,251772 Albania,Europe,3.2,11100 What is the first line of the file created by the following code? Dim query = From line In IO.File.ReadAllLines("UN.txt") Let data = line.Split(","c) Let country = data(0) Let population = 1000000 * CDbl(data(2)) Select country & "," & population IO.File.WriteAllLines("NewFile.txt", query) (A) Afganistan,28.2 (B) Afganistan,28,200,000 (C) Afganistan,28200000 (D) country,population Answer C 8. Each line of the file UN.txt contains four pieces of information (name, continent, population in millions, area) about one of the 192 member countries of the United Nations. The first two lines of the file are Afghanistan,Asia,28.2,251772 Albania,Europe,3.2,11100 What is the first line of the file created by the following code? Dim query = From line In IO.File.ReadAllLines("UN.txt") Let data = line.Split(","c) Let country = data(0) Let population = 1000000 * CDbl(data(2)) Let area = CDbl(data(3)) Let density = population / area Select country & "," & density.ToString("N1") IO.File.WriteAllLines("NewFile.txt", query) (A) Afganistan,28200000/251772 (B) Afganistan,112.0 (C) Afganistan,112.006100757829 (D) country,density Answer is B
Image of page 2
9. What elements are in the array newArray after the following code is executed? Dim firstArray() As Integer = {1, 2, 3} Dim secondArray() As Integer = {3, 4, 5, 6} Dim newArray() As Integer = firstArray.Intersect(secondArray).ToArray (A) 1, 2, 3, 3, 4, 5, 6 (B) 1, 2, 3, 4, 5, 6 (C) 3 (D) 1, 2 Answer is C 10. What elements are in the array newArray after the following code is executed? Dim firstArray() As
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Image of page 4
This is the end of the preview. Sign up to access the rest of the document.
  • Winter '17
  • .NET Framework

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern