Search Suggest

Core Java - Interview Questions and Answers

351. Which of the following are true?
a) The InputStream and OutputStream classes are byte-oriented.
b) The ObjectInputStream and ObjectOutputStream do not support serialized object input and output.
c) The Reader and Writer classes are character-oriented.
d) The Reader and Writer classes are the preferred solution to serialized object output.

Ans : a and c.

352. Which of the following are true about I/O filters?
a) Filters are supported on input, but not on output.
b) Filters are supported by the InputStream/OutputStream class hierarchy, but not by the Reader/Writer class hierarchy.
c) Filters read from one stream and write to another.
d) A filter may alter data that is read from one stream and written to another.

Ans : c and d.

353. Which of the following are true?
a) Any Unicode character is represented using 16-bits.
b) 7-bits are needed to represent any ASCII character.
c) UTF-8 characters are represented using only 8-bits.
d) UTF-16 characters are represented using only 16-bits.

Ans : a and b.

354. Which of the following are true?
a) The Serializable interface is used to identify objects that may be written to an output stream.
b) The Externalizable interface is implemented by classes that control the way in which their objects are serialized.
c) The Serializable interface extends the Externalizable interface.
d) The Externalizable interface extends the Serializable interface.

Ans : a, b and d.

355. Which of the following are true about the File class?
a) A File object can be used to change the current working directory.
b) A File object can be used to access the files in the current directory.
c) File objects are used to access files and directories on the local file system.
d) File objects can be garbage collected.
e) When a File object is garbage collected, the corresponding file or directory is deleted.

Ans : b, d and e.

356. How do you create a Reader object from an InputStream object?
a) Use the static createReader( ) method of InputStream class.
b) Use the static createReader( ) method of Reader class.
c) Create an InputStreamReader object, passing the InputStream object as an argument to the InputStreamReader constructor.
d) Create an OutputStreamReader object, passing the InputStream object as an argument to the OutputStreamReader constructor.

Ans : c.

357. Which of the following are true?
a) Writer classes can be used to write characters to output streams using different character encodings.
b) Writer classes can be used to write Unicode characters to output streams.
c) Writer classes have methods that support the writing of the values of any Java primitive type to output streams.
d) Writer classes have methods that support the writing of objects to output streams.

Ans : a and b.

358. The isFile( ) method returns a boolean value depending on whether the file object is a file or a directory.
True / False.

Ans : True.

359. Reading or writing can be done even after closing the input/output source.
True/False.

Ans : b.

360. The ________ method helps in clearing the buffer.

Ans : flush( ).

إرسال تعليق