Exam 13: File Input and Output

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

Permanent storage is usually called computer memory or random access memory (RAM).

Free
(True/False)
4.8/5
(38)
Correct Answer:
Verified

False

InputStream and OutputStream are subclasses of the ____ class.

Free
(Multiple Choice)
4.9/5
(34)
Correct Answer:
Verified

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:
Verified

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)

How can you categorize files by the way they store data?

(Essay)
4.9/5
(31)

In random access files, records can be retrieved in any order.

(True/False)
4.9/5
(43)

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:
Verified
Premises:
Responses:
Temporary storage
static import feature
(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:
Verified
Premises:
Responses:
Writes text to an output stream, buffering the characters
batch processing
(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:
Verified
Premises:
Responses:
To make files no longer available to your application
data file
(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:
Verified
Premises:
Responses:
Clears any bytes that have been sent to a buffer for output but have not yet been output to a hardware device
buffer
(Matching)
4.9/5
(29)
Showing 1 - 20 of 78
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)