Java Quiz Day 54

Last Updated :
Discuss
Comments

Question 1

What is the advantage of using buffered I/O streams over unbuffered I/O streams?

  • Buffered I/O streams provide better performance by reducing the number of read and write operations

  • Buffered I/O streams are slower than unbuffered I/O streams

  • Buffered I/O streams are used for reading binary data

  • Buffered I/O streams can only be used for reading files

Question 2

Which class in Java provides methods for buffered output to files?

  • FileOutputStream

  • BufferedWriter

  • PrintWriter

  • FileWriter

Question 3

Which of the following methods is used to read a line of text from a file using BufferedReader?

  • readLine()

  • read()

  • readText()

  • nextLine()

Question 4

What is the purpose of object serialization in Java?

  • To convert an object into a format that can be easily saved to a file or transmitted over a network

  • To copy an object’s data to another object

  • To load an object from a file

  • To convert object data into character format

Question 5

Which class is used to serialize an object in Java?

  • ObjectOutputStream

  • ObjectReader

  • BufferedWriter

  • ObjectInputStream

Question 6

Which method of ObjectOutputStream is used to write an object to a file?

  • writeObject()

  • serializeObject()

  • saveObject()

  • writeFile()

Question 7

Which of the following is required for a class to be serializable in Java?

  • The class must implement the Serializable interface

  • The class must extend the Object class

  • The class must have a no-argument constructor

  • The class must be thread-safe

Question 8

Which class is used to deserialize an object in Java?

  • ObjectInputStream

  • ObjectReader

  • ObjectOutputStream

  • FileReader

Question 9

Which of the following is true about serialization in Java?

  • It allows objects to be converted into byte streams and restored later

  • It can only be used with primitive data types

  • It is only supported for objects that implement Cloneable

  • It is used to create threads from objects

Question 10

What happens if a class that implements Serializable does not mark a field as transient?

  • The field will be excluded from serialization

  • The field will be serialized

  • The class will not compile

  • An exception will be thrown during runtime

There are 10 questions to complete.

Take a part in the ongoing discussion