Quiz on Chapter 11
This page contains questions on Chapter 11 of Introduction to Programming Using Java. You should be able to answer these questions after studying that chapter. Sample answers to these questions can be found here.
In Java, input/output is done using streams. Streams are an abstraction. Explain what this means and why it is important.
Java has two types of streams: character streams and byte streams. Why? What is the difference between the two types of streams?
What is a file? Why are files necessary?
What is the point of the following statement?
out = new PrintWriter( new FileWriter("data.dat") );
Why would you need a statement that involves two different stream classes, PrintWriter and FileWriter?
The package java.io includes a class named URL. What does an object of type URL represent, and how is it used?
What is the purpose of the JFileChooser class?
Explain what is meant by the client / server model of network communication.
What is a socket?
What is a ServerSocket and how is it used?
What is meant by an element in an XML document?
What is it about XML that makes it suitable for representing almost any type of data?
Write a complete program that will display the first ten lines from a text file. The lines should be written to standard output, System.out. The file name is given as the command-line argument args. You can assume that the file contains at least ten lines. Don't bother to make the program robust. Do not use TextIO to process the file; use a FileReader to access the file.