Top 150+ Java Interview Questions and Answers

    58 Votes

130. Why should we use object serialization?

Object serialization takes an object's state, and converts it to a stream of data. With object serialization, it's very easy to make any object persistent, without writing custom code to save object member variables.
131. How to prevent writing some member data value during object serialization?

The transient keyword is used to indicate the JVM that the variables that are marked as transient in an object is not part of the persistent state of the object and it should be excluded while saving the object.

132. What are Reader and Writer classes?
Reading and writing character streams are handled by Reader and Writer classes. These classes are abstractions that Java provides for dealing with reading and writing character data.
133. Give few examples of simple Reader and Writer classes?
  • FileReader and FileWriter : Read data from or write data to a file on the native file system.
  • PipedReader and PipedWriter : They are used to channel the output of a program or thread into the input of another program or thread. 
  • CharArrayReader and CharArrayWriter : Read data from or write data to a char array in memory.


134. What are FilterReader/FilterWriter, BufferedReader/BufferedWriter and PrintWriter?

  • FilterReader and FilterWriters are subclasses of Reader and Writer, respectively. These classes define the interface for filtered streams which process data as it's being read or written.
  • BufferedReader and BufferedWriter : They buffer data while reading or writing, in order to reduce the number of read/write access on the original data source.
  • PrintWriter : An output stream with convenient print methods

135. What is a File class?

It represents a file on the native file system. We can create a File object for each file in the file system, so that we fetch the information about the file from the object. For example, Name, Full pathname etc.

136. What are the functionalaties we get using File class?

The File class in the package provides various methods to access the properties of a file or a directory, such as file permissions, date and time of creation, and path of a directory.

Java Interview Questions on Threads

137. What are the benefit's of using threads in an application?

  • It improves performance .
  • It minimizes system resource usage. 
  • We can access multiple applications simultaneously. 
  • Threads simplifies the program structure.
  • We can send & receive data on the network at the same time.
  • We can read & write files to disk simultaneously.

138. What are the differences between process and threads?


It is an executable program loaded in the memory. It has its own address space – variables & data structures (in memory). Process communicates via the operating system, files, network. A process may contain multiple threads.


It is sequentially executed stream of instructions. It shares an address space with other threads and it has it's own execution context.

139. What are the types of thread?

There are two types of thread:

  • Single Threaded Process
  • Multi Threaded Process

140. What is single threaded and multi threaded process?

  • Single Threaded Process: A thread is defined as the independent path of execution within a program. A process that is made of one thread is known as single-threaded process.
  • Multi Threaded Process: A process that creates two or more threads is called a multithreaded process.
Page 12 of 14

Popular Videos


How to improve your Interview, Salary Negotiation, Communication & Presentation Skills.

Got a tip or Question?
Let us know

Related Articles

Java OOPS Interview Questions and Answers
Top Advanced Java Interview Questions and Answers
Java Collections Interview Questions and Answers
Java Thread Interview Questions and Answers