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
Which class in VB.NET is used for reading binary files? a) BinaryReader b) StreamReader c) FileStream d) FileReader
What method is used to write to a binary file in VB.NET? a) Write() b) WriteByte() c) WriteLine() d) BinaryWrite()
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()
Which class is used for writing binary data in VB.NET? a) FileWriter b) BinaryWriter c) StreamWriter d) FileStreamWriter
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
Which class is used to load XML data in VB.NET? a) XmlReader b) XmlDocument c) XmlSerializer d) FileReader
How can you save an XML document in VB.NET? a) xml.Save() b) xml.Write() c) xml.Export() d) xml.SaveToFile()
Which class in VB.NET is used to read XML files? a) XmlReader b) StreamReader c) XmlSerializer d) FileReader
What method is used to create an XmlDocument object? a) New XmlDocument() b) CreateXml() c) LoadXml() d) XmlDocument()
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
Which namespace is used for JSON serialization and deserialization in VB.NET? a) System.IO b) System.Text c) System.JSON d) Newtonsoft.Json
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()
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()
What is the default format for JSON in VB.NET? a) Plain text b) Array c) Object-based d) XML-like
What type of object is returned when deserializing JSON data into a VB.NET object? a) ArrayList b) Dictionary c) Custom Object d) String
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
Which class in VB.NET is commonly used to deserialize JSON strings into objects? a) JsonReader b) JsonSerializer c) JsonConvert d) JsonDataReader
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
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()
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
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
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
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
What does the JsonConvert.DeserializeObject() method return? a) String b) Object c) Boolean d) List
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
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
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
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
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
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