True or False. State reason 1 )The next method reads a string that is delimited
ID: 3734372 • Letter: T
Question
True or False. State reason
1 )The next method reads a string that is delimited by whitespace.
2) To read an entire line of a file, use the next() method.
3) To check if a character is lower case, use the isLowerCase method.
4) When you are done processing a file, you need to close the Scanner or PrintWriter.
5) The Scanner class is used to read from a file.
6) To write to a file with the PrintWriter class, we use the print, println, and printf methods.
7)When writing to a file using the PrintWriter class, if the file already exist, the new data being written to the file is placed after the old data already in the file.
8)When opening a file, if the file doesn't exist, an exception occurs.
Explanation / Answer
1 )The next method reads a string that is delimited by whitespace.
Answer:
False
Explanation:
The next() method reads a string delimited by delimiters, but nextLineO reads a line ending with a line separator.
2) To read an entire line of a file, use the next() method.
Answer:
False
Explanation:
When each line of a file is a data record, it is often best to read entire lines with the nextLine method.
The method next() is used when a file is used as an iterator, typically in a loop, the next() method is called repeatedly. This method returns the next input line, or raises StopIteration when EOF is hit. Combining next() method with other file methods like readline() does not work right.
3) To check if a character is lower case, use the isLowerCase method.
Answer:
True
Explanation:
isLowerCase(char ch) java method determines if the specified character is alowercase character.
4) When you are done processing a file, you need to close the Scanner or PrintWriter.
Answer:
True
Explanation:
Close all files when you are done processing them. When you are done processing a file, be sure to close the Scanner or PrintWrite.
5) The Scanner class is used to read from a file.
Answer:
True
Explanation:
To create an object of Scanner class, we usually pass the predefined object System.in, which represents the standard input stream. We may pass an object of class File if we want to read input from a file. To read numerical values of a certain data type XYZ, the function to use is nextXYZ()
6) To write to a file with the PrintWriter class, we use the print, println, and printf methods.
Answer:
True
Explanation:
You can use the familiar print, println, and printf methods with any PrintWriter object: Close all files when you are done processing them.
7)When writing to a file using the PrintWriter class, if the file already exist, the new data being written to the file is placed after the old data already in the file.
Answer:
False
Explanation:
write text to a file - java.io.PrintWriter(String fileName) throws FileNotFoundException - attach a writer to fileName - if file already exists, old contents are deleted before new data is added -if file doesn't exist, empty file is created - exception thrown if no file with that name exists
8)When opening a file, if the file doesn't exist, an exception occurs.
Answer:
True
Explanation:
Opens the file for reading and writing; an exception occurs if the file doesn't exist
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.