Java - IO - Interview Questions

Java provides the Java IO Api to read from and write to data sources through input and output classes. Java IO interview questions are frequently asked in Java interview, especially during telephonic screening and initial rounds.

You knowledge of Java IO Api will also be tested sometimes during algorithmic or coding interviews which involve reading or writing data to sources such as files.

Below Java IO interview questions, answers, tips and samples will get you grounded on the fundamentals, important methods to remember, and some of the basic operations that you will perform using Java IO such as reading or writing to files etc.

Important keywords are provided at the end of below Java IO interview questions. Review them, make them a part of Java IO vocabulary, and talk about them confidently during your interview process.

What are the I/O streams Java programming language?

 FAQ

I/O streams in Java programming language represent input sources from which data is read, and output destinations to which data is written. Streams support different kinds of data including bytes, characters, primitive types and objects.

Byte Streams - java.io package has two abstract classes InputStream and OutputStream that represents input stream and output stream of byte data type.

Character Streams - java.io package has two abstract classes Reader and Writer that represents input stream and output stream of character data type.

Primitive data streams- java.io package has two interfaces classes DataInput and DataOutput that represents input stream and output stream of primitive data type.

Object streams- java.io package has two interfaces ObjectInput and ObjectOutput that represents input stream and output stream of object data type.

What are Byte Streams in Java programming language?

 FAQ

Byte streams handle the I/O of raw binary data. Byte streams represent low-level I/O which are usually used for primitive I/O operations.

All byte stream classes in Java programming language extend from InputStream and OutpotStream. Some of the classes provided in Java programming language that are based on byte streams are - FileInputStream and FileOutputStream which handle the byte I/O of files, ByteArrayInputStream and ByteArrayOutputStream which perform byte I/O operations on a byte array, StringBufferInputStream and StringBufferOutputStream which perform byte I/O operations on strings, ObjectInputStrean and ObjectOutputStream which perform byte I/O operations on objects.

What are character streams in Java programming language?

 FAQ

Character streams handle the I/O operations of character data sets.

All character stream classes in Java programming language implements from Reader and Writer interfaces. Some of the classes provided in Java programming language that are based on character streams are - InputStreamReader and InputStreamWriter which are byte-to-character 'bridge' streams, CharArrayReader and CharArrayWriter which perform byte I/O operations on a char arrays, StringReader and StringWriter which perform character I/O operations on strings, FileReader and FileWriter which perform byte I/O operations on character files.

What are Buffered streams in Java programming language?

 FAQ

Buffered streams provide buffered functionality to unbuffered streams by wrapping them.

Buffered streams perform I/O operations on buffers, and call native OS API only when the buffer is empty. This makes buffered streams highly more efficient than unbuffered streams.

Java I/O follows decorator pattern by enabling wrapping of one stream with another, i.e an unbuffered stream is wrapped with a buffered stream to provide buffered I/O operations.

Java programming language provides BufferdInputStream and BufferedOutputStream classes that wrap byte streams, and BufferedReader and BufferedWriter classes that wrap character streams.

What are Data streams in Java programming language?

 FAQ

Data streams provide binary I/O operations on primitive data (short, int, long, float, double, char, byte and boolean) and on strings. All data streams implement either the DataInput interface or the DataOutput interface

Java Interview Guide has over 250 REAL questions from REAL interviews. Get the guide for $15.00 only.
 
BUY EBOOK
 

What are Object streams in Java programming language?

 FAQ

Object streams provide I/O operations on objects. Objects have to be serializable in order for object streams to operate on them...

*** See complete answer in the Java Interview Guide.

What are scanners in Java programming language?

 FAQ

Java programming language provides the Scanner class that enables splitting of string and primitive data into separate tokens...

*** See complete answer in the Java Interview Guide.

 
Java Interview Guide

$15.00

BUY EBOOK
  SSL Secure Payment
Java Interview Quesiuons - Secure Payment
Java Interview Guide

$15.00

BUY EBOOK
  SSL Secure Payment
Java Interview Quesiuons - Secure Payment
 

Java - Interview Questions

Java - Object Oriented ProgrammingJava - Objects & ClassesJava - Data TypesJava - VariablesJava - StringsJava - ArraysJava - CollectionsJava - ReflectionJava - Lambda ExpressionsJava - StreamsJava - GenericsJava - ExceptionsJava - IOJava - ThreadsJava - ConcurrencyJava - JDBCJava - NetworkingJava - SecurityJava - JVM InternalsJava - PerformanceJava - New in Java 8Java - New in Java 9Java - New in Java 10Java - New in Java 11
 
MASTER Java  

Top ranked courses to help you master Java skills.
Java Programming Masterclass

iconicon

Offered By - Tim Buchalka
Platform - Udemy
Rating - * * * * *
Students Enrolled - 575,000 +

RECOMMENDED RESOURCES
Behaviorial Interview
Top resource to prepare for behaviorial and situational interview questions.

STAR Interview Example