Download as pdf or txt
Download as pdf or txt
You are on page 1of 38

Absolute Java 5th Edition Walter

Savitch Test Bank


Go to download the full and correct content document:
https://testbankfan.com/product/absolute-java-5th-edition-walter-savitch-test-bank/
More products digital (pdf, epub, mobi) instant
download maybe you interests ...

Absolute Java 5th Edition Walter Savitch Solutions


Manual

https://testbankfan.com/product/absolute-java-5th-edition-walter-
savitch-solutions-manual/

Absolute Java 6th Edition Savitch Test Bank

https://testbankfan.com/product/absolute-java-6th-edition-
savitch-test-bank/

Absolute C++ 5th Edition Savitch Test Bank

https://testbankfan.com/product/absolute-c-5th-edition-savitch-
test-bank/

Absolute C++ 5th Edition Savitch Solutions Manual

https://testbankfan.com/product/absolute-c-5th-edition-savitch-
solutions-manual/
Absolute C++ 6th Edition Savitch Test Bank

https://testbankfan.com/product/absolute-c-6th-edition-savitch-
test-bank/

Absolute C++ 6th Edition Savitch Solutions Manual

https://testbankfan.com/product/absolute-c-6th-edition-savitch-
solutions-manual/

Big Java Early Objects 5th Edition Horstmann Test Bank

https://testbankfan.com/product/big-java-early-objects-5th-
edition-horstmann-test-bank/

Problem Solving with C++ 9th Edition Savitch Test Bank

https://testbankfan.com/product/problem-solving-with-c-9th-
edition-savitch-test-bank/

Problem Solving with C++ 10th Edition Savitch Test Bank

https://testbankfan.com/product/problem-solving-with-c-10th-
edition-savitch-test-bank/
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

2) An ____________ allows data to flow from your program.


(a) input stream
(b) output stream
(c) file name
(d) all of the above
Answer: B

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

4) The output stream connected to the computer screen is:


(a) System.exit
(b) System.quit
(c) System.in
(d) System.out
Answer: D

©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

8) All of the following are methods of the Scanner class except:


(a) nextFloat()
(b) next()
(c) useDelimiter()
(d) readLine()
Answer: D

9) The method _________ reads a single character from an input stream.


(a) readLine()
(b) skip()
(c) read()
(d) close()
Answer: C

©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

3) The FileNotFoundException is a descendant of the class IOException.


Answer: True

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"));

3) Explain what happens when an output file is opened in Java.


Answer: In Java, when an output stream is connected to a file, the program always starts with an
empty file. If the file you are trying to connect to exists, the contents of the file are deleted before
the output stream writes new data to the file. If the file you are trying to connect to does not exist,
then a new empty file is created.

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

public static String getFileName() throws IOException

BufferedReader stdin = new BufferedReader(new

InputStreamReader(System.in));

System.out.print("Enter the name of the file to open: ");

String fileName = stdin.readLine();

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");

6) What happens when the method close is invoked on a stream?


Answer: When the close method is invoked, the system releases any resources used to connect the
stream to the file and does any other housekeeping that is needed.

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:

PrintWriter outputStream = null;

try

©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
Chapter 10 File I/O 7

outputStream = new PrintWriter(new

FileOutputStream("statistics.txt"));

outputStream.println(24);

outputStream.println(55);

outputStream.println(76);

outputStream.close();

catch(FileNotFoundException e)

System.out.println("Error opening the file autos.txt");

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;

public class TextDemo

public static void main(String args[])

BufferedReader inputStream = null;

try

inputStream = new BufferedReader(new FileReader("autos.txt"));

String line = inputStream.readLine();

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)

System.out.println("Error opening files.");

catch(IOException e)

System.out.println("Error reading from file.");

11) Write a Java statement that creates an output stream to a binary file named statistics.dat.
Answer:

ObjectOutputStream outputStream =

new ObjectOutputStream(new FileOutputStream("statistics.dat"));

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 =

new ObjectInputStream(new FileInputStream("statistics.dat"));

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;

public class BinaryInputDemo

public static void main(String args[])

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)

System.out.println("End of file encountered");

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

System.out.println("Unable to locate file");

catch(IOException e)

System.out.println("Unable to read file");

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;

public class TextDemo

©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
Chapter 10 File I/O 13

public static void main(String args[])

Scanner inputStream = null;

try

inputStream = new Scanner(new FileReader("autos.txt"));

String line = inputStream.nextLine();

while(line != null)

System.out.println(line);

line = inputStream.nextLine();

inputStream.close();

catch(FileNotFoundException e)

System.out.println("Error opening files.");

©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.
Another random document with
no related content on Scribd:
The Project Gutenberg eBook of Les Climats
This ebook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this ebook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

Title: Les Climats

Author: Anna de Noailles

Illustrator: François-Louis Schmied

Release date: August 9, 2022 [eBook #68719]

Language: French

Original publication: France: Société du livre contemporain, 1924

Credits: Laurent Vogel, Chuck Greif and the Online Distributed


Proofreading Team at https://www.pgdp.net (This file
was produced from images generously made available
by the Bibliothèque nationale de France (BnF/Gallica))

*** START OF THE PROJECT GUTENBERG EBOOK LES CLIMATS


***
L E S C L I M AT S

Cette édition établie par


F-L. SCHMIED
pour la Société du
LIVRE CONTEMPORAIN
et sous la direction de Eug.
Renevey et H. Michel-Dansac
a été tirée à 125 exemplaires.

Dépôt légal
T U V I E NS D E T R OP G O NF L E R MO N CŒUR
P O UR L’ E S PA C E Q U I L E C O NT I E NT.. .

SHAKESPEARE
CO MTE S S E D E N O AIL LE S

LES
C L I MAT S

SOCIÉTÉ DU LIVRE CONTEMPORAIN

P A R I S 1924
TABLE DES
POÈMES
SYRACUSE
Excite maintenant tes compagnons du
chœur à célébrer l’illustre Syracuse!...
PINDARE.

e me souviens d’un chant du coq, à Syracuse!


Le matin s’éveillait, tempétueux et chaud;
La mer, que parcourait un vent large et dispos,
Dansait, ivre de force et de lumière infuse!

Sur le port, assailli par les flots aveuglants,


Des matelots clouaient des tonneaux et des caisses,
Et le bruit des marteaux montait dans la fournaise
Du jour, de tous ces jours glorieux, vains et lents;

J’étais triste. La ville illustre et misérable


Semblait un Prométhée sur le roc attaché;
Dans le grésillement marmoréen du sable
Piétinaient les troupeaux qui sortaient des étables;
Et, comme un crissement de métal ébréché,
Des cigales mordaient un blé blanc et séché.

Les persiennes semblaient à jamais retombées


Sur le large vitrail des palais somnolents;
Les balcons espagnols accrochaient aux murs blancs
Broyés par le soleil, leurs ferrures bombées:
Noirs cadenas scellés au granit pantelant...

Dans le musée, mordu ainsi qu’un coquillage


Par la ruse marine et la clarté de l’air,
Des bustes sommeillaient,—dolents, calmes visages,
Qui s’imprègnent encor, par l’éclatant vitrage,
Qu s p èg e t e co , pa éc ata t v t age,
De la vigueur saline et du limpide éther.

Une craie enflammée enveloppait les arbres;


Les torrents secs n’étaient que des ravins épars,
De vifs géraniums, déchirant le regard,
Roulaient leurs pourpres flots dans ces blancheurs de marbre...
Je sentais s’insérer et brûler dans mes yeux
Cet éclat forcené, inhumain et pierreux.

Une suture en feu joignait l’onde au rivage.


J’étais triste, le jour passait. La jaune fleur
Des grenadiers flambait, lampe dans le feuillage.
Une source, fuyant l’étreignante chaleur,
Désertait en chantant l’aride paysage.

Parfois sur les gazons brûlés, le pourpre épi


Des trèfles incarnats, le lin, les scabieuses,
Jonchaient par écheveaux la plaine soleilleuse,
Et l’herbage luisait comme un vivant tapis
Que n’ont pas achevé les frivoles tisseuses.

Le théâtre des Grecs, cirque torride et blond,


Gisait. Sous un mûrier, une auberge voisine
Vendait de l’eau: je vis, dans l’étroite cuisine,
Les olives s’ouvrir sous les coups du pilon
Tandis qu’on recueillait l’huile odorante et fine.

Et puis vint le doux soir. Les feuilles des figuiers


Caressaient, doigts légers, les murailles bleuâtres.
D’humbles, graves passants s’interpellaient; les pieds
Des chevreaux au poil blanc, serrés autour du pâtre,
Faisaient monter du sol une poudre d’albâtre.

U l i tt d l li t
Un calme inattendu, comme un plus pur climat,
Ne laissait percevoir que le chant des colombes.
Au port, de verts fanaux s’allumaient sur les mâts,
Et l’instant semblait fier, comme après les combats
Un nom chargé d’honneur sur une jeune tombe.
C’était l’heure où tout luit et murmure plus bas...

La fontaine Aréthuse, enclose d’un grillage,


Et portant sans orgueil un renom fabuleux,
Faisait un bruit léger de pleurs et de feuillage
Dans les frais papyrus, élancés et moelleux...

Enfin ce fut la nuit, nuit qui toujours étonne


Par l’insistante angoisse et la muette ardeur.
La lune plongeait, telle une blanche colonne,
Dans la rade aux flots noirs, sa brillante liqueur.

Un solitaire ennui aux astres se raconte:


Je contemplais le globe au front mystérieux,
Et qui, ruine auguste et calme dans les cieux,
Semble un fragment divin, retiré, radieux
De vos temples, Géla, Ségeste, Sélinonte!

O nuit de Syracuse: Urne aux flancs arrondis!


Logique de Platon! Ame de Pythagore!
Ancien Testament des Hellènes; amphore
Qui verses dans les cœurs un vin sombre et hardi,
Je sais bien les secrets que ton ombre m’a dits.

Je sais que tout l’espace est empli du courage


Qu’exhalèrent les Grecs aux genoux bondissants;
Les chauds rayons des nuits, la vapeur des nuages
Sont faits avec leur voix, leurs regards et leur sang.
Je sais que des soldats, du haut des promontoires,
Chantant des vers sacrés et saluant le sort,
Se jetaient en riant aux gouffres de la mort
Pour retomber vivants dans la sublime Histoire!

Ainsi ma nuit passait. L’ache, l’anet crépu


Répandaient leurs senteurs. Je regardais la rade;
La paix régnait partout où courut Alcibiade,
Mais,—noble obsession des âges révolus,—
L’éther semblait empli de ce qui n’était plus...

J’entendis sonner l’heure au noir couvent des Carmes.


L’espace regorgeait d’un parfum d’orangers.
J’écoutais dans les airs un vague appel aux armes...
Et le pouvoir des nuits se mit à propager
L’amoureuse espérance et ses divins dangers:

O désir du désir, du hasard et des larmes!


LES SOIRS DU MONDE
soirs que tant d’amour oppresse,
Nul œil n’a jamais regardé
Avec plus de tendre tristesse
Vos beaux ciels pâles et fardés!
J’ai délaissé dès mon enfance
Tous les jeux et tous les regards,
Pour voguer sans peur, sans défense,
Sur vos étangs qui veillent tard.

Par vos langueurs à la dérive,


Par votre tiède oisiveté,
Vous attirez l’âme plaintive
Dans les abîmes de l’été...

O soir naïf de la Zélande,


Qui, timide, ingénu, riant,
Semblez raconter la légende
Des pourpres étés d’Orient!

Soir romain, aride malaise,


Et ce cri d’un oiseau perdu
Au-dessus du palais Farnèse,
Dans le ciel si sec, si tendu!

Soir bleu de Palerme embaumée,


Où les parfums épais, fumants,
S’ajoutent à la nuit pâmée
Comme un plus fougueux élément.

Sur la vague tyrrhénienne,


Dans une vapeur indigo,
Un voilier fend l’onde païenne
Et dit: «Je suis la nef Argo!»
Et dit: «Je suis la nef Argo!»

Par des ruisseaux couleur de jade,


Dans des senteurs de mimosa,
La fontaine arabe s’évade,
Au palais roux de la Ziza.

Dans le chaud bassin du Musée,


Les verts papyrus, s’effilant,
Suspendent leur fraîche fusée
A l’azur sourd et pantelant:

O douceur de rêver, d’attendre


Dans ce cloître aux loisirs altiers
Où la vie est inerte et tendre
Comme un repos sous les dattiers!

Catane où la lune d’albâtre


Fait bondir la chèvre angora,
Compagne indocile du pâtre
Sur la montagne des cédrats!

Derrière des rideaux de perles,


Chez les beaux marchands indolents,
Des monceaux de fraises déferlent
Au bord luisant des vases blancs.

Quels soupirs, quand le soir dépose


Dans l’ombre un surcroît de chaleur!
L’œillet, comme une pomme rose,
Laisse pendre sa lourde fleur.

L’emportement de l’azur brise


L h d it il d b t

You might also like