Absolute Java 5th Edition Walter Savitch Test Bank - Latest Version Can Be Downloaded Immediately
Absolute Java 5th Edition Walter Savitch Test Bank - Latest Version Can Be Downloaded Immediately
com
https://testbankfan.com/product/absolute-java-5th-edition-
walter-savitch-test-bank/
OR CLICK BUTTON
DOWLOAD NOW
https://testbankfan.com/product/absolute-java-5th-edition-walter-
savitch-solutions-manual/
testbankfan.com
https://testbankfan.com/product/absolute-java-6th-edition-savitch-
test-bank/
testbankfan.com
https://testbankfan.com/product/absolute-c-5th-edition-savitch-test-
bank/
testbankfan.com
https://testbankfan.com/product/introduction-to-law-6th-edition-hames-
test-bank/
testbankfan.com
Marketing Research 6th Edition Burns Test Bank
https://testbankfan.com/product/marketing-research-6th-edition-burns-
test-bank/
testbankfan.com
https://testbankfan.com/product/pathway-to-introductory-
statistics-1st-edition-lehmann-test-bank/
testbankfan.com
https://testbankfan.com/product/our-sexuality-12th-edition-crooks-
solutions-manual/
testbankfan.com
https://testbankfan.com/product/marketing-14th-edition-kerin-test-
bank/
testbankfan.com
https://testbankfan.com/product/corporate-finance-principles-
practice-7th-edition-watson-solutions-manual/
testbankfan.com
Biological Science Canadian 2nd Edition Freeman Test Bank
https://testbankfan.com/product/biological-science-canadian-2nd-
edition-freeman-test-bank/
testbankfan.com
Chapter 10
File I/O
◼ Multiple Choice
1) An ___________ allows data to flow into your program.
(a) input stream
(b) output stream
(c) file name
(d) all of the above
Answer: A
3) Files whose contents must be handled as sequences of binary digits are called:
(a) text files
(b) ASCII files
(c) binary files
(d) output files
Answer: C
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
1
2 Walter Savitch • Absolute Java 5/e Chapter 10 Test Bank
5) In Java, when you open a text file you should account for a possible:
(a) FileNotFoundException
(b) FileFullException
(c) FileNotReadyException
(d) all of the above
Answer: A
6) There are two common classes used for reading from a text file. They are:
(a) PrintWriter and BufferedReader
(b) FileInputStream and Scanner
(c) BufferedReader and Scanner
(d) None of the above
Answer: C
7) The scanner class has a series of methods that checks to see if there is any more well-formed input
of the appropriate type. These methods are called __________ methods:
(a) nextToken
(b) hasNext
(c) getNext
(d) testNext
Answer: B
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
Chapter 10 File I/O 3
10) When the method readLine() tries to read beyond the end of a file, it returns the value of:
(a) 1
(b) -1
(c) null
(d) none of the above
Answer: C
11) A __________ path name gives the path to a file, starting with the directory that the program is in.
(a) relative
(b) descendant
(c) full
(d) complete
Answer: A
12) The stream that is automatically available to your Java code is:
(a) System.out
(b) System.in
(c) System.err
(d) all of the above
Answer: D
13) All of the following are methods of the File class except:
(a) exists()
(b) delete()
(c) getDirectory()
(d) getName()
Answer: C
14) The class ObjectOutputStream contains all of the following methods except:
(a) writeInt()
(b) writeChar()
(c) writeDouble()
(d) println()
Answer: D
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
4 Walter Savitch • Absolute Java 5/e Chapter 10 Test Bank
15) The method __________ from the File class forces a physical write to the file of any data that is
buffered.
(a) close()
(b) flush()
(c) writeUTF()
(d) writeObject()
Answer: B
16) The class ObjectInputStream contains all of the following methods except:
(a) readLine()
(b) readChar()
(c) readObject()
(d) readInt()
Answer: A
17) The read() method of the class RandomAccessFile returns the type:
(a) byte
(b) int
(c) char
(d) double
Answer: B
◼ True/False
1) A stream is an object that allows for the flow of data between your program and some I/O device or
some file.
Answer: True
2) Every input file and every output file used by your program has only one name which is the same
name used by the operating system.
Answer: False
4) When your program is finished writing to a file, it should close the stream connected to that file.
Answer: True
5) Only the classes provided for file output contain a method named close.
Answer: False
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
Chapter 10 File I/O 5
6) The methods of the scanner class do not behave the same when reading from a text file as they do
when used to read from the keyboard.
Answer: False
7) Using BufferedReader to read integers from a file requires the String input to be parsed to an integer
type.
Answer: True
8) A full path name gives a complete path name, starting from the directory the program is in.
Answer: False
9) The File class contains methods that allow you to check various properties of a file.
Answer: True
10) Binary files store data in the same format that is used by any common text editor.
Answer: False
11) Binary files can be handled more efficiently than text files.
Answer: True
12) The preferred stream classes for processing binary files are ObjectInputStream and
ObjectOutputStream.
Answer: True
◼ Short Answer/Essay
1) Explain the differences between a text file, an ASCII file and a binary file.
Answer: Text files are files that appear to contain sequences of characters when viewed in a text
editor or read by a program. Text files are sometimes also called ASCII files because they contain
data encoded using a scheme known as ASCII coding. Files whose contents must be handled as
sequences of binary digits are called binary files.
2) Write a Java statement to create and open an output stream to a file named autos.txt.
Answer: PrintWriter outputStream = new PrintWriter(new FileOutputStream("autos.txt"));
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
6 Walter Savitch • Absolute Java 5/e Chapter 10 Test Bank
4) Write a Java method that returns a String representing a file name entered by the user. Use the
BufferedReader class to obtain input.
Answer:
InputStreamReader(System.in));
return fileName.trim();
5) Use the output stream to the file autos.txt created above in number 2 to write the line “Mercedes” to
the file.
Answer: outputStream.println("Mercedes");
7) Create try and catch block that opens a file named statistics.txt for output. Writes the integers 24,
55, and 76 to the file, and then closes the file.
Answer:
try
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
Chapter 10 File I/O 7
FileOutputStream("statistics.txt"));
outputStream.println(24);
outputStream.println(55);
outputStream.println(76);
outputStream.close();
catch(FileNotFoundException e)
System.exit(0);
8) Write a Java statement that creates an output stream to append data to a file named autos.txt.
Answer: PrintWriter outputStream = new PrintWriter(new FileOutputStream("autos.txt", true));
9) Write a Java statement to create an input stream to a file named autos.txt. Use the BufferedReader
class.
Answer: BufferedReader inputStream = new BufferedReader(new FileReader("autos.txt"));
10) Write a complete Java program using a BufferedReader object that opens a file named autos.txt and
displays each line to the screen.
Answer:
import java.io.BufferedReader;
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
8 Walter Savitch • Absolute Java 5/e Chapter 10 Test Bank
import java.io.FileReader;
import java.io.FileNotFoundException;
import java.io.IOException;
try
while(line != null)
System.out.println(line);
line = inputStream.readLine();
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
Chapter 10 File I/O 9
inputStream.close();
catch(FileNotFoundException e)
catch(IOException e)
11) Write a Java statement that creates an output stream to a binary file named statistics.dat.
Answer:
ObjectOutputStream outputStream =
12) Use the output stream created in number 11 above to write the String BBC to the file named
statistics.dat.
Answer: outputStream.writeUTF("BBC");
13) Write a Java statement to create an input stream to the binary file statistics.dat.
Answer:
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
10 Walter Savitch • Absolute Java 5/e Chapter 10 Test Bank
ObjectInputStream inputStream =
14) Write a complete Java program that opens a binary file containing integers and displays the contents
to the screen.
Answer:
import java.io.ObjectInputStream;
import java.io.FileInputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.FileNotFoundException;
try
ObjectInputStream inputStream =
new ObjectInputStream(new
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
Chapter 10 File I/O 11
FileInputStream("statistics.dat"));
int stat = 0;
try
while(true)
stat = inputStream.readInt();
System.out.println(stat);
catch(EOFException e)
inputStream.close();
catch(FileNotFoundException e)
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
12 Walter Savitch • Absolute Java 5/e Chapter 10 Test Bank
catch(IOException e)
15) Write a Java statement that creates a stream that provides read/write access to the file named
autos.txt.
Answer: RandomAccessFile ioStream = new RandomAccessFile("autos.txt", "rw");
16) Write a Java statement to create an input stream to a file named “statistics.dat”.
Answer: Scanner inputStream = new Scanner(new FileReader("statistics.dat"));
17) Write a complete Java program using a Scanner object that opens a file named autos.txt and displays
each line to the screen.
Answer:
import java.util.*;
import java.io.FileReader;
import java.io.FileNotFoundException;
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
Chapter 10 File I/O 13
try
while(line != null)
System.out.println(line);
line = inputStream.nextLine();
inputStream.close();
catch(FileNotFoundException e)
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
14 Walter Savitch • Absolute Java 5/e Chapter 10 Test Bank
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
Random documents with unrelated
content Scribd suggests to you:
101 Ophth. Atlas, Taf. vi. Fig. 2.
DISEASES OF THE SKIN.—The eczema of the lower lid, nose, angle of the
mouth, and external meatus of the ear which so frequently
accompanies the phlyctenular conjunctivitis of scrofulous children is
probably the most common example of coincident skin and eye
disease. Lepra is a frequent cause of severe affections of the eye in
localities where it is endemic. Bull and Hansen105 assert that the
cornea is frequently attacked. They divide the manifestations of the
disease upon this membrane into two varieties—the one in which
there is a diffuse infiltration of the tissue, and the other where there
is a formation of tubers. The first variety is a gray opacity limited to
the border of the cornea, not separated from its circumference by
any such clear area as is found in arcus senilis. This opacity becomes
vascularized, and may remain quiet for years till another attack of
hyperæmia occurs, which, also in time receding, leaves the tissue
more opaque than before. In the second there are nodes which
appear to start at the margin of the cornea and to accompany either
its superficial or its deep layer of vessel-loops: this latter form is
more dangerous to vision. The paralysis of the orbicularis muscle
which is a frequent attendant upon the smooth form of the disease
allows an exposure of the membrane to irritants which often
produce a third form of inflammation. The iris also exhibits the
smooth and the tuberous forms of the disease. Iritis occurring in
lepra is, however, by no means pathognomonic; 50 per cent. of all
cases exhibiting synechiæ are the result of extensions of corneal
inflammations due to orbicular paralysis. The superciliæ and the
eyelashes are said to be frequent seats of leprous tubercules. In the
lids the first symptom is the falling of the eyelashes, which is
dependent upon the formation of the tubers before they become
manifest to sight and touch. Mooren106 maintains that chronic skin
eruptions favor the development of cataract by causing creeping
inflammatory processes which alter the character of the exudations
into the vitreous humor, and moreover claims that when such skin
eruptions have their seat in the scalp they favor the occurrence of
retinitis by maintaining a constant hyperæmia of the meninges. He
further cites a case where he observed a decrease in the acuity of
vision corresponding with the breaking out of a skin eruption, and an
increase in the power of vision coincident with the disappearance of
the eruption. Foerster107 agrees with Mooren in the statement that
cataract may be formed in cases where chronic skin affections favor
the development of marasmus. Rothmund108 reports a noteworthy
curiosity to the effect that cataract followed a peculiar degeneration
of the skin in three families living in separate villages in the
Urarlberg. The skin of these patients showed a fatty degeneration of
the rete Malpighii and of the papillæ, with consecutive thinning and
atrophy of the epidermis: this was most marked on the cheeks, chin,
and the outer surfaces of the arms and legs. In the individuals thus
affected the skin disease commenced between the third and sixth
months of life, whilst the cataract appeared in both eyes between
the third and sixth years. Rothmund thinks that the same congenital
predisposition to disease exists in both organs, because the lens is
developed out of an unfolding of the external skin.
105 The Leprous Diseases of the Eye, Christiana, 1873.
125 Die Krankheiten des Auges, 1863, Bd. ii. pp. 167, 269.
131 De Morbis Oculi humani que e Variolis exedi, etc., Leipzig, 1871.
134 August Andreæ, Grundriss der Gesammten Augenheilkunde, vol. ii. p. 260.
144 Lectures on the Parts concerned in the Operations in the Eye, London, 1870, p.
110.
150 "Post-febrile Ophthalmitis," Monthly Journ. Med. Sci., 1845, pp. 723-729.
152 "Entzündung der Vorderen Abschnitten der Choroidea als Nachkrankheit der
Febris Recurrens," A. f. O., Bd. xvi., 1, S. 352-363.
155 Klin. Darstellung der Krankheiten des Auges, 1881, pp. 289-291.
testbankfan.com