Core Java - Interview Questions and Answers for 'Writer' | Search Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com

Search Interview Questions


 More than 3000 questions in repository.
 There are more than 900 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

   



Core Java - Interview Questions and Answers for 'Writer' - 7 question(s) found - Order By Rating

 Q1. How does encoding affect using Reader / writer classes or Stream classes in Java ? Core Java
Ans. Which group of bytes represent which character is defined by character encoding. So when reading character by character from a stream of bytes using Reader, specifying character encoding becomes significant as the same group of bytes can represent different character in different character encoding(Eg UTF-8 and UTF-16 etc.)

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     File io  File handling  Reader  Writer  Stream     Asked in 1 Companies


 Q2. How and when the Buffer is cleared when using Buffered Writer Classes ?Core Java
Ans. Buffer is cleared in 2 circumstances, i.e 1. naturally when the buffer is filled and 2. explicitly when the method flush is called ( for flushing the residual )

Ideally we just need to call flush once at the end of file writing so that the residual content should be dumped to file.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     BufferedWriter  Writer  PrintWriter  File io  flush  file handling


 Q3. Tell something about BufferedWriter ? What are flush() and close() used for ?
Ans. BufferedWriter is temporary source for data storage.BufferedWriter is used to write character data to the file.Flush() is method available in B.W which ensures that all data items are written to file including last character.Close() is used to closes the character output stream.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   java io   input output   file handling   file io   output stream   bufferedwriter   flush   close


 Q4. What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?Core Java
Ans. The Reader/Writer class hierarchy is character-oriented, and the InputStream/OutputStream class hierarchy is byte-oriented

  Sample Code for InputStream

  Sample Code for OutputStream

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   file io   streams   reader class   writer class   inputstream   outputstream   stream  file handling


 Q5. Which is the abstract parent class of FileWriter ?Core Java
Ans. OutputStreamWriter

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   io   file   fileio   filewriter   outputstreamwriter  file handling


 Q6. Which of the following code is correct ?

a.


FileWriter fileWriter = new FileWriter("../file.txt");
File file = new File(fileWriter );
BufferedWriter bufferedOutputWriter = new BufferedWriter(fileWriter);

b.

BufferedWriter bufferedOutputWriter = new BufferedWriter("../file.txt");
File file = new File(bufferedOutputWriter );
FileWriter fileWriter = new FileWriter(file);


c.

File file = new File("../file.txt");
FileWriter fileWriter = new FileWriter(file);
BufferedWriter bufferedOutputWriter = new BufferedWriter(fileWriter);

d.

File file = new File("../file.txt");
BufferedWriter bufferedOutputWriter = new BufferedWriter(file);
FileWriter fileWriter = new FileWriter(bufferedOutputWriter );
Core Java
Ans. c.

File file = new File("../file.txt");
FileWriter fileWriter = new FileWriter(file);
BufferedWriter bufferedOutputWriter = new BufferedWriter(fileWriter);

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   io   file   fileio   coding   code   filewriter   bufferedwriter   scjp   ocjp  file handling


 Q7. Name few Writer classes ?
Ans. http://www.buggybread.com/2015/01/java-output-writer-classes-and.html

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   input output   io   writer



Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: