English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Which of the following statements is true the BufferReader class in Java and why?

OPTIONS:

(A) This class reads text from a character output stream.
(B) This class allows reading only one character at a time
(C) This class allows you to wrap any subclass of the Reader class with any other subclass of the reader class.
(D) This class buffers the data to increase performance.

2006-10-08 18:36:55 · 2 answers · asked by K Sengupta 4 in Computers & Internet Programming & Design

2 answers

The answer is D, as indicated in the below javadoc:

* Read text from a character-input stream, buffering characters so as to
* provide for the efficient reading of characters, arrays, and lines.
*
*

The buffer size may be specified, or the default size may be used. The
* default is large enough for most purposes.
*
*

In general, each read request made of a Reader causes a corresponding
* read request to be made of the underlying character or byte stream. It is
* therefore advisable to wrap a BufferedReader around any Reader whose read()
* operations may be costly, such as FileReaders and InputStreamReaders. For
* example,
*
*


* BufferedReader in
* = new BufferedReader(new FileReader("foo.in"));
*

*
* will buffer the input from the specified file. Without buffering, each
* invocation of read() or readLine() could cause bytes to be read from the
* file, converted into characters, and then returned, which can be very
* inefficient.
*
*

Programs that use DataInputStreams for textual input can be localized by
* replacing each DataInputStream with an appropriate BufferedReader.

2006-10-08 18:58:02 · answer #1 · answered by addtheninth 2 · 0 0

A,B OPTIONS ARE TRUE

2006-10-09 01:44:23 · answer #2 · answered by ch_nagarajind 3 · 0 0

fedest.com, questions and answers