Visual Programming MCQs with Answers
Practice important Visual Programming MCQs with answers and explanations.
Chapter: 10
Q261:
What will the following code print if the xmlReader reads a Cube element with attributes?
A. currency: rate
B. currency and rate values
C. currency
D. rate
Correct Answer:
B
Chapter: 10
Q262:
What does the SelectSingleNode method do in XmlDocument?
A. Selects all nodes matching the XPath expression
B. Selects a single node matching the XPath expression
C. Loads the XML document from a file
D. Creates a new node in the XML document
Correct Answer:
B
Chapter: 10
Q263:
What is the primary use of XML in programming?
A. Exchanging data between applications
B. Storing code execution instructions
C. Providing compile-time metadata
D. Managing application resources
Correct Answer:
A
Chapter: 11
Q264:
What is the purpose of an extension method in C#?
A. To create a new class
B. To simplify code by adding methods to existing types
C. To replace existing methods
D. To handle file operations
Correct Answer:
B
Chapter: 11
Q265:
How do you use an extension method for a string in C#?
A. By using the Extension keyword
B. By calling it on the string variable directly
C. By modifying the string class directly
D. By declaring a new method in the myutils class
Correct Answer:
B
Chapter: 11
Q266:
What method is used to read the entire content of a file in C#?
A. File.Read
B. File.ReadAllText
C. File.ReadFrom
D. File.ReadContent
Correct Answer:
B
Chapter: 11
Q267:
How can you write text to a file in C#?
A. File.WriteText
B. File.WriteAllText
C. File.Write
D. File.AppendText
Correct Answer:
B
Chapter: 11
Q268:
What is the correct method to append text to an existing file in C#?
A. File.AppendAllText
B. File.WriteAllText
C. File.AppendText
D. File.AddText
Correct Answer:
A
Chapter: 11
Q269:
How do you delete a file using C#?
A. File.DeleteFile("filename")
B. File.Remove("filename")
C. File.Delete("filename")
D. File.RemoveFile("filename")
Correct Answer:
C
Chapter: 11
Q270:
What method is used to rename a file in C#?
A. File.Move
B. File.Rename
C. File.ChangeName
D. File.UpdateName
Correct Answer:
A
Chapter: 11
Q271:
How do you create a new directory in C#?
A. Directory.Make
B. Directory.CreateNew
C. Directory.CreateDirectory
D. Directory.Add
Correct Answer:
C
Chapter: 11
Q272:
What does the FileInfo class provide?
A. Information about directories
B. Information about file attributes
C. Information about file content
D. Information about file system operations
Correct Answer:
B
Chapter: 11
Q273:
How can you retrieve a list of files in a directory using DirectoryInfo?
A. di.GetFiles()
B. di.ListFiles()
C. di.FetchFiles()
D. di.ListAllFiles()
Correct Answer:
A
Chapter: 11
Q274:
What is the purpose of using reflection in C#?
A. To improve file handling
B. To retrieve information about types and methods
C. To manage file and directory operations
D. To handle exception handling
Correct Answer:
B
Chapter: 11
Q275:
How can you get the type information of an object using reflection?
A. object.GetType()
B. object.GetTypeInfo()
C. Type.GetType()
D. object.TypeInfo()
Correct Answer:
A
Chapter: 11
Q276:
How do you obtain all the types defined in an assembly using reflection?
A. Assembly.GetTypes()
B. Assembly.GetAllTypes()
C. Assembly.ListTypes()
D. Assembly.GetDefinedTypes()
Correct Answer:
A
Chapter: 11
Q277:
What method allows you to invoke a method using reflection?
A. MethodInfo.Invoke()
B. Method.Invoke()
C. MethodInfo.Call()
D. Method.InvokeMethod()
Correct Answer:
A
Chapter: 11
Q278:
How does PropertyInfo.SetValue work in reflection?
A. Sets the value of a property
B. Retrieves the value of a property
C. Updates the property metadata
D. Deletes the property value
Correct Answer:
A
Chapter: 11
Q279:
What is the purpose of StreamWriter in file handling?
A. To read files
B. To write text to files
C. To delete files
D. To append text to files
Correct Answer:
B
Chapter: 11
Q280:
How do you safely handle file operations to ensure the file is closed properly?
A. Using FileHandler
B. Using StreamWriter with using block
C. Directly managing file handles
D. Using FileManager
Correct Answer:
B