Exam 13: File Input and Output
Exam 1: Creating Your First Java Classes76 Questions
Exam 2: Using Data81 Questions
Exam 3: Using Methods, Classes and Objects79 Questions
Exam 4: More Object Concepts84 Questions
Exam 5: Making Decisions80 Questions
Exam 6: Looping77 Questions
Exam 7: Characters, Strings and the Stringbuilder82 Questions
Exam 8: Arrays77 Questions
Exam 9: Advanced Array Concepts80 Questions
Exam 10: Introduction to Inheritance78 Questions
Exam 11: Advanced Inheritance Concepts78 Questions
Exam 12: Exception Handling79 Questions
Exam 13: File Input and Output78 Questions
Exam 14: Introduction to Swing Components79 Questions
Exam 15: Using Javafx and Scene Builder65 Questions
Select questions type
Permanent storage is usually called computer memory or random access memory (RAM).
Free
(True/False)
4.8/5
(38)
Correct Answer:
False
InputStream and OutputStream are subclasses of the ____ class.
Free
(Multiple Choice)
4.9/5
(34)
Correct Answer:
B
The value you store in memory is lost when the program ends or the computer loses power. This type of storage device is called ____.
Free
(Multiple Choice)
4.8/5
(49)
Correct Answer:
C
Describe and provide an example of the differences between real-time applications and interactive programs.
(Essay)
4.8/5
(43)
When a String is written, placing each record on a new line makes the output file easier to read and interpret. Since not all platforms use '\n' to separate lines, the BufferedWriter class has two alternatives: the newLine() method and the System.getProperty() method. Describe these two methods and how they operate.
(Essay)
4.8/5
(44)
import java.nio.file.*;
import java.io.*;
import static java.nio.file.StandardOpenOption.*;
public class WriteFile
{
public static void main(String[] args)
{
Path myFile = Paths.get("C:\\Java\\Input.Output\\myNumbers.txt");
String nums = "12345";
byte[] data = nums.getBytes();
OutputStream output = null;
try
{
-----Code here------
output.write(data)
output.flush();
output.close();
}
catch(Exception badNums)
{
System.out.println("My numbers: " + badNums);
}
}
}
Using the above code, add a statement on the indicated line that will create a writeable file by constructing a BufferedOutputStream object and assigning it to the OutputStream . No output should appear on the monitor, but a file should be created.
(Essay)
4.9/5
(39)
FileSystems is a class that contains ____ methods, which assist in object creation.
(Multiple Choice)
4.8/5
(46)
When you perform input and output operations in an application, what is actually occurring with the bytes of information?
(Essay)
4.8/5
(40)
The ____ method returns the last Path element in a list of pathnames.
(Multiple Choice)
4.8/5
(33)
import java.util.Scanner;
import java.nio.file.*;
public class PathDemo2
{
public static void main(String[] args)
{
String name;
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter a file name >> ");
name = keyboard.nextLine();
Path inputPath = Paths.get(name);
------- Code here -----
System.out.println("Full path is " + fullPath.toString());
}
}
Using the above code, add a statement on the indicated line that creates an absolute path by assigning the file to the current directory.
(Essay)
4.8/5
(40)
Match each term with the correct statement below.
Premises:
Temporary storage
Responses:
static import feature
BufferedWriter
flushing
Correct Answer:
Premises:
Responses:
(Matching)
4.8/5
(33)
import java.nio.file.*;
import static java.nio.file.AccessMode.*;
import java.io.IOException;
public class PathDemo3
{
public static void main(String[] args)
{
Path myFile = Paths.get("C:\\Java\\Chapter.13\\Data.txt");
System.out.println("Path is " + myFile.toString());
try {
-------------- Code here -------------------
System.out.println("File can be read and executed"); }
catch(IOException e)
{
System.out.println("File cannot be used for this application");
}
}
}
Assuming you have declared a path named myFile , create the checkAccess() method on the indicated line that will verify that the file exists, and checks that the program can read and write to the file.
(Essay)
4.8/5
(39)
When you use the BufferedReader class, you must import the java.io package into your program.
(True/False)
4.8/5
(35)
Placing a file in the ____ directory of your storage device is equivalent to tossing a loose document into a drawer.
(Multiple Choice)
4.8/5
(35)
Match each term with the correct statement below.
Premises:
Writes text to an output stream, buffering the characters
Responses:
batch processing
instant access files
seekable
Correct Answer:
Premises:
Responses:
(Matching)
5.0/5
(38)
Match each term with the correct statement below.
Premises:
To make files no longer available to your application
Responses:
data file
batch processing
buffer
Correct Answer:
Premises:
Responses:
(Matching)
4.9/5
(43)
The top-level element in a Path 's directory structure is located at index 1.
(True/False)
4.7/5
(36)
Match each term with the correct statement below.
Premises:
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
Responses:
buffer
stream
absolute path
Correct Answer:
Premises:
Responses:
(Matching)
4.9/5
(29)
Showing 1 - 20 of 78
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)