Visual Programming MCQs with Answers
Practice important Visual Programming MCQs with answers and explanations.
Multiple Choice Questions
Q251: What is the correct syntax to declare an anonymous method that takes no parameters?
- A: delegate { /* code */ };
- B: delegate() { /* code */ };
- C: delegate(object sender) { /* code */ };
- D: delegate void() { /* code */ };
View Answer
A
Q252: What does the ?? operator do with nullable types in C#?
- A: Converts a nullable type to a non-nullable type
- B: Provides a default value if the nullable type is null
- C: Forces a nullable type to be non-nullable
- D: Checks if a nullable type is equal to zero
View Answer
B
Q253: What does the finally block in a try-catch-finally statement ensure in C#?
- A: It allows the program to continue without interruption
- B: It executes code regardless of whether an exception is thrown
- C: It handles exceptions that are not caught
- D: It stops the program from executing further
View Answer
B
Q254: Which class in C# allows you to read XML data one element at a time?
- A: XmlDocument
- B: XmlReader
- C: XmlWriter
- D: XmlSerializer
View Answer
B
Q255: How does XmlReader differ from XmlDocument in handling XML data?
- A: XmlReader loads the entire document into memory
- B: XmlDocument is faster and uses less memory
- C: XmlDocument reads one element at a time
- D: XmlReader is more memory efficient and faster
View Answer
D
Q256: What is the default underlying type of an enum in C#?
- A: byte
- B: short
- C: int
- D: long
View Answer
C
Q257: How do you create a nullable integer in C#?
- A: int? myValue = null;
- B: int myValue = null;
- C: Nullable
myValue = null; - D: Nullable myValue = null;
View Answer
A
Q258: What method would you use to get a list of all the element names in an XML document using XmlDocument?
- A: GetElementsByTagName
- B: SelectNodes
- C: GetNodeNames
- D: SelectSingleNode
View Answer
B
Q259: Which XML class in C# is used for creating or writing XML data?
- A: XmlReader
- B: XmlWriter
- C: XmlDocument
- D: XmlSerializer
View Answer
B
Q260: How do you write an XML document to a file using XmlWriter in C#?
- A: XmlWriter.WriteFile("file.xml");
- B: XmlWriter.Save("file.xml");
- C: XmlWriter.Create("file.xml");
- D: XmlWriter.Open("file.xml");
View Answer
C