MCQs on File Handling and Serialization | Visual Basic .NET (VB.NET)

Explore 30 multiple-choice questions (MCQs) focused on file handling and serialization in VB.NET, covering binary file operations, XML file handling, and JSON serialization. Improve your knowledge with these essential programming topics.


MCQs on File Handling and Serialization

Reading and Writing Binary Files

  1. Which class in VB.NET is used for reading binary files?
    a) BinaryReader
    b) StreamReader
    c) FileStream
    d) FileReader
  2. What method is used to write to a binary file in VB.NET?
    a) Write()
    b) WriteByte()
    c) WriteLine()
    d) BinaryWrite()
  3. How do you read a binary file using a BinaryReader in VB.NET?
    a) reader.Read()
    b) reader.ReadByte()
    c) reader.ReadAll()
    d) reader.ReadLine()
  4. Which class is used for writing binary data in VB.NET?
    a) FileWriter
    b) BinaryWriter
    c) StreamWriter
    d) FileStreamWriter
  5. What is the primary purpose of using BinaryReader and BinaryWriter classes?
    a) Read and write text files
    b) Read and write binary data
    c) Serialize and deserialize data
    d) Handle XML data

Working with XML Files

  1. Which class is used to load XML data in VB.NET?
    a) XmlReader
    b) XmlDocument
    c) XmlSerializer
    d) FileReader
  2. How can you save an XML document in VB.NET?
    a) xml.Save()
    b) xml.Write()
    c) xml.Export()
    d) xml.SaveToFile()
  3. Which class in VB.NET is used to read XML files?
    a) XmlReader
    b) StreamReader
    c) XmlSerializer
    d) FileReader
  4. What method is used to create an XmlDocument object?
    a) New XmlDocument()
    b) CreateXml()
    c) LoadXml()
    d) XmlDocument()
  5. How do you add a new element to an XML file in VB.NET?
    a) AddChild()
    b) AppendChild()
    c) InsertChild()
    d) CreateElement()

JSON Serialization and Deserialization

  1. Which namespace is used for JSON serialization and deserialization in VB.NET?
    a) System.IO
    b) System.Text
    c) System.JSON
    d) Newtonsoft.Json
  2. What method is used to serialize an object into a JSON string in VB.NET?
    a) Json.Serialize()
    b) JsonConvert.SerializeObject()
    c) JsonWriter.Serialize()
    d) Json.SerializeObject()
  3. Which method is used to deserialize JSON data into an object in VB.NET?
    a) JsonConvert.DeserializeObject()
    b) DeserializeJson()
    c) Json.Deserialize()
    d) JsonConvert.Deserialize()
  4. What is the default format for JSON in VB.NET?
    a) Plain text
    b) Array
    c) Object-based
    d) XML-like
  5. What type of object is returned when deserializing JSON data into a VB.NET object?
    a) ArrayList
    b) Dictionary
    c) Custom Object
    d) String
  6. What is the primary use of JSON serialization in VB.NET?
    a) Store data in a file
    b) Transfer data between applications
    c) Encrypt data
    d) Execute remote functions
  7. Which class in VB.NET is commonly used to deserialize JSON strings into objects?
    a) JsonReader
    b) JsonSerializer
    c) JsonConvert
    d) JsonDataReader
  8. What does the “JsonConvert.SerializeObject()” method do in VB.NET?
    a) Reads a JSON file
    b) Converts an object to JSON format
    c) Deserializes JSON data
    d) Converts a JSON string into an object
  9. Which VB.NET method is used to write JSON data to a file?
    a) File.WriteAllText()
    b) JsonFile.Write()
    c) JsonWriter.Write()
    d) File.WriteJson()
  10. How do you handle JSON data without using external libraries in VB.NET?
    a) Use XmlSerializer
    b) Use manual string manipulation
    c) Use Newtonsoft.Json library
    d) Use XmlDocument
  11. What happens if the structure of a JSON string does not match the target object when deserializing?
    a) An exception is thrown
    b) It silently ignores the mismatch
    c) The deserialization is incomplete
    d) It defaults to null
  12. How do you define custom rules for JSON serialization in VB.NET?
    a) Use attributes like JsonIgnore
    b) Set public properties
    c) Use configuration settings
    d) Manually write serialization code
  13. Which library is most commonly used for JSON handling in VB.NET?
    a) System.Json
    b) Newtonsoft.Json
    c) Json.NET
    d) System.Text.Json
  14. What does the JsonConvert.DeserializeObject() method return?
    a) String
    b) Object
    c) Boolean
    d) List
  15. In JSON serialization, what happens to private members of an object?
    a) They are serialized by default
    b) They are ignored by default
    c) They are serialized if explicitly marked
    d) They cause an error
  16. How do you exclude a property from being serialized in JSON?
    a) Use [JsonIgnore] attribute
    b) Use [Serialize] attribute
    c) Make the property private
    d) Use [Exclude] attribute
  17. What is one of the key advantages of JSON over XML?
    a) It is easier to read
    b) It is more flexible
    c) It is better for binary data
    d) It has better encryption
  18. Which of the following is true about JSON in VB.NET?
    a) It uses a strict schema
    b) It supports only arrays
    c) It is a lightweight data-interchange format
    d) It cannot be deserialized
  19. What is the main difference between JSON and XML in terms of structure?
    a) JSON uses key-value pairs, while XML uses tags
    b) JSON is more verbose than XML
    c) JSON cannot handle hierarchical data
    d) XML is only used for text data
  20. Which of the following best describes JSON in VB.NET?
    a) A programming language
    b) A file format
    c) A lightweight data-interchange format
    d) A database

Answer Table

QnoAnswer (Option with the text)
1a) BinaryReader
2b) WriteByte()
3b) reader.ReadByte()
4b) BinaryWriter
5b) Read and write binary data
6b) XmlDocument
7a) xml.Save()
8a) XmlReader
9a) New XmlDocument()
10b) AppendChild()
11d) Newtonsoft.Json
12b) JsonConvert.SerializeObject()
13a) JsonConvert.DeserializeObject()
14c) Object-based
15c) Custom Object
16b) Transfer data between applications
17c) JsonConvert
18b) Converts an object to JSON format
19a) File.WriteAllText()
20b) Use manual string manipulation
21a) An exception is thrown
22a) Use attributes like JsonIgnore
23b) Newtonsoft.Json
24b) Object
25b) They are ignored by default
26a) Use [JsonIgnore] attribute
27a) It is easier to read
28c) It is a lightweight data-interchange format
29a) JSON uses key-value pairs, while XML uses tags
30c) A lightweight data-interchange format

Use a Blank Sheet, Note your Answers and Finally tally with our answer at last. Give Yourself Score.

X
error: Content is protected !!
Scroll to Top