Web Design and Development MCQs with Answers
Practice important Web Design and Development MCQs with answers and explanations.
Multiple Choice Questions
Q341: What is the purpose of the Serializable interface in Java?
- A: To define methods for object serialization
- B: To indicate that a class can be serialized
- C: To handle object input and output streams
- D: To perform encryption on object data
View Answer
B
Q342: Which Java class is used to write objects to a file?
- A: FileInputStream
- B: FileOutputStream
- C: ObjectInputStream
- D: ObjectOutputStream
View Answer
D
Q343: What method is used to read an object from a file in Java serialization?
- A: readObject()
- B: writeObject()
- C: readFile()
- D: writeFile()
View Answer
A
Q344: In the provided WriteEx example, what is the name of the file where the PersonInfo object is serialized?
- A: person.dat
- B: ali.dat
- C: object.dat
- D: file.dat
View Answer
B
Q345: What keyword is used to prevent a field from being serialized?
- A: static
- B: transient
- C: volatile
- D: final
View Answer
B
Q346: How does the ClientWriteNetEx class send an object over a network?
- A: Using FileOutputStream
- B: Using Socket and ObjectOutputStream
- C: Using DataOutputStream
- D: Using PrintWriter
View Answer
B
Q347: What must be done when reading a serialized object from a stream?
- A: Cast the object to the correct type
- B: Decrypt the object
- C: Convert the object to a string
- D: Compress the object
View Answer
A
Q348: How does the ServerReadNetEx class handle incoming connections?
- A: By creating a new Socket for each connection
- B: By using ServerSocket to accept connections
- C: By using ObjectOutputStream to receive objects
- D: By handling FileInputStream
View Answer
B
Q349: What is the role of transient keyword in Java serialization?
- A: To mark fields that are not part of the object’s state
- B: To encrypt the fields during serialization
- C: To ensure fields are serialized in binary format
- D: To define methods for serialization
View Answer
A
Q350: What method is used to write an object to a network stream?
- A: writeObject()
- B: sendObject()
- C: writeStream()
- D: sendStream()
View Answer
A