Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

CSE110 Principles of Programming with Java Quiz M14 Last Name (print: First Name

ID: 3820915 • Letter: C

Question

CSE110 Principles of Programming with Java Quiz M14 Last Name (print: First Name (print): 1. Which of the following is the correct way to create a Scanner object to read text from an input file data tt? [1 pt] A: Scanner input File new Scanner data.txt B: File the File new File data.txt scanner input File new Scanner (the File) Scanner input File new Scanner ("data.txt File the File new File (input, File) D: Scanner input F new File ("data.txt 2. Which of the following is the correct way to create a PrintWriter object to write text to an output file results.txt? [1 pt] A: Print Writer output File new PrintStream sults B: Print writer output File new File ("results .txt") Scanner the File new Scanner results .txt File) Print writer output File new writer (the txt i Printwriter output File Print Writer ("results 3. Assuming that output File is a valid Printwriter object, which of the following statements would cause a compile-time error? [1 pt] A: output File print ("The End B: output File-close outputFile print f ("E8.2f", Math.sqrt (3.0)) D: output File println ("88.2f", Math.sqrt (3.0) 4. Select the output generated by the code segment below, assuming that data is a Scanner object used to read the following text: 1234 E Phoenix Avenue, Arizona, AZ 80500. int count 0; while (da La hasNext string input data.next (li count System out printin (count) A: 7 B: 8 5. Assume pr is a Printwriter object which was created already, write print statements to print the following inside the corresponding text file. [2 ptsl String name: double height John Smith 6.15 Height:

Explanation / Answer

Hi, I have answered first 4 questions.

Please repost others in separate post.

Please let me know in case of any issue in answered part.


1.
   B

   File theFile = new File("data.txt");
   Scanner inputFile = new Scanner(theFile);

2. Ans: D

3. ans: D
   We can only specify format specifier in printf function

4. Ans: A 7
   next() function read word by word