Important Web Design and Development Short Questions
Chapter: 8
Question 1:
What is the difference between Node Streams and Filter Streams in Java?
Answer:
Node Streams connect directly to the data source/sink, while Filter Streams enhance functionality by sitting on top of Node Streams, providing features like buffering.
Chapter: 8
Question 2:
Give an example of a Node Stream in Java.
Answer:
An example of a Node Stream is FileReader, which directly connects to a file to read its data.
Chapter: 8
Question 3:
What additional functionality do Filter Streams provide in Java?
Answer:
Filter Streams add features such as buffering, compression, and security by sitting on top of Node Streams, enhancing the base functionality.
Chapter: 8
Question 4:
How are byte-oriented and character-oriented streams different in Java?
Answer:
Byte-oriented streams (e.g., FileInputStream) handle data in bytes, while character-oriented streams (e.g., FileReader) handle data in characters.
Chapter: 8
Question 5:
How does Java handle data reading from different sources, such as files and networks, uniformly?
Answer:
Java uses streams to uniformly handle data from various sources, allowing the same code structure for reading from files, networks, or the console.
Chapter: 8
Question 6:
What does the BufferedReader class do when reading data?
Answer:
BufferedReader enhances input efficiency by buffering the data before it is read, reducing the number of I/O operations.
Chapter: 8
Question 7:
How does the FileReader class function in Java?
Answer:
FileReader is a Node Stream in Java that reads character data from a file. It directly connects to the file specified in its constructor.
Chapter: 8
Question 8:
Describe a scenario where you would use a PrintWriter in Java.
Answer:
PrintWriter is used when you need to write character data to a file or another output stream, with features like automatic line flushing for efficient output handling.
Chapter: 8
Question 9:
What happens if the file specified in FileWriter does not exist?
Answer:
If the file specified in FileWriter does not exist, Java will automatically create it.
Chapter: 8
Question 10:
How does Java handle exceptions during file operations?
Answer:
Java uses try-catch blocks to handle exceptions, such as IOException, that may occur during file operations like reading or writing.