Chapter 14: Files and Streams - Christopher Newport Univer



CPSC150 EH35

Q1:          are synchronized communication channels between threads.

a. Files.

b. Buffers.

c. Interfaces.

d. Pipes.

Q2:          is an I/O performance enhancement technique.

a. Buffering.

b. Piping.

c. Pushback.

d. Transaction processing.

Q3: In addition to byte-based streams, Java provides the          and          abstract classes, which are Unicode two-byte, character-based streams.

a. InputStream and OutputStream.

b. CharArrayReader and CharArrayWriter.

c. Reader and Writer.

d. StringReader and StringWriter.

Q4: Which method call enables users to specify files and directories from a JFileChooser?

a. setFileSelectionMode( FILES_OR_DIRECTORIES );

b. showOpenDialog( FILES_AND_DIRECTORIES );

c. showOpenDialog( FILES_OR_DIRECTORIES );

d. None of the above.

Q5: Which JFileChooser method returns the file the user selected.

a. getSelectedFile.

b. getFile.

c. getOpenDialog.

d. showOpenDialog.

Q6:

Standard telephone keypads contain the digits zero through nine. The number two through nine each have three letters associated with them (see the following table). Many people find it dificult to memorize phonn numbers, so they use the correspondence between digits and letters to develop seven-letter words that correspond to their phone numbers. For example, a person whose telephone number is 686-2377 might use the correspondence indicated in the table to develop the seven-letter word “NUMBERS.” Every seven-letter word corresponds to exactly one seven-digit telephone number. A restaurant wishint to increase its takeout business could surely do so with the number 825-3688 (i.e., “TAKEOUT”).

Every seven-letter phone number corresponds to many different seven-letter words. Unfortunately, most of these words represent unrecognizable juxtapositions of letters. It is possible, however, that the owner of a barbershop would be pleased to kno that the shop’s telephone number, 424-7288, corresponds to “HAIRCUT.” The owner of a liquor store would, no doubt, be delighted to find that the store’s number, 233-7226, corresponds to “BEERCAN.” A veterinarian with the phonn number 738-2273 would be pleased to know that the number corresponds the letters “PETCARE.” At automotive dealship would be pleased to know that the dealship number, 639-2277, corresponds to “NEWCARS.”

Write a program that, given a seven-digit number, uses a PrintStream object to write to a file every possible seven-letter word combination corresponding to that number. There are 2,187 (37) such combinaion. Avoid phone numbers with the digits 0 and 1.

|Digit |Letters |

|2 |A B C |

|3 |D E F |

|4 |G H I |

|5 |J K L |

|6 |M N O |

|7 |P R S |

|8 |T U V |

|9 |W X Y |

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download