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

Search Java Interview Questions


 2137 questions in repository.
 There are more than 200 unanswered questions.
Click here and help us by providing the answer.
Label / Company      Label / Company / Text

   



Interview Questions and Answers for 'Reader' - 5 question(s) found - Order By Newest

 Q1. What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?Core Java
Admin
info@buggybread.com
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


 Q2. Which class is used to read streams of characters from a file?Core Java
Admin
info@buggybread.com
Ans. FileReader

  Sample Code for FileReader

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

   Like      Discuss      Correct / Improve     java   io   file   fileio   filereader  file handling


 Q3. Name few Reader classes ?
Admin
info@buggybread.com
Ans. http://www.buggybread.com/2015/01/java-input-reader-classes-and-interfaces.html

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

   Like      Discuss      Correct / Improve     java   input output   io   reader


 Q4. Difference between Scanner and BufferedReader ? Which one is faster and Why ?Core Java
Admin
info@buggybread.com
Ans. Scanner is used for parsing tokens from the contents of the stream while BufferedReader just reads the stream.

BufferedReader read files efficiently by using a buffer to avoid physical disk operations.

Buffer size of Scanner is usually smaller than the Buffered Writer.

BufferedReader is faster that Scanner as it just reads the Stream and doesn't Parse the tokens to read the stream into primitive data types.

  Sample Code for Scanner

  Sample Code for BufferedReader

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

   Like      Discuss      Correct / Improve     java   file io   input output   scanner   bufferedreader  file handling


 Q5. Write a program that reads file using FileReader and BufferedReaderCore Java2016-08-18 10:18:03

Ans. File file = new File("/home/sample.txt");
FileReader fileReader = new FileReader(file);
BufferedReader bufferedReader = new BufferedReader(fileReader);
while ((line = bufferedReader.readLine()) != null) {
System.out.println(line);
}

  Sample Code for import java.io.BufferedReader; import java.io.File; import java.io.FileReader;

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

   Like      Discuss      Correct / Improve     File handling  FileReader  BufferedReader




Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus
 

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:
         

X Close this

X Close this

Help Us Improve.
Please share your
interview experience.

Company Name:   


Questions Asked: