Visual Programming MCQs with Answers
Practice important Visual Programming MCQs with answers and explanations.
Multiple Choice Questions
Q241: Which of the following is a generic collection in C#?
- A: ArrayList
- B: List
- C: Hashtable
- D: Queue
View Answer
B
Q242: How do you add an item to a List<int> in C#?
- A: list.Add(1);
- B: list[0] = 1;
- C: list.Insert(0, 1);
- D: list.Append(1);
View Answer
A
Q243: What method is used to retrieve the number of elements in a List<int>?
- A: Count()
- B: Length()
- C: Size()
- D: Count
View Answer
D
Q244: Which statement is true about operator overloading?
- A: Operators can only be overloaded for classes
- B: Overloaded operators must be static
- C: Operators can be overloaded for all types
- D: Overloading changes operator precedence
View Answer
B
Q245: What does the [STAThread] attribute signify?
- A: Single-threaded apartment model
- B: Multi-threaded apartment model
- C: Single-threaded application
- D: Static threading attribute
View Answer
A
Q246: Which attribute is used to mark a method as compliant with the CLS?
- A: STAThread
- B: Obsolete
- C: CLSCompliant
- D: Serializable
View Answer
C
Q247: What is the purpose of the Dictionary<int, Customer> collection?
- A: To store key-value pairs
- B: To store a list of customers
- C: To sort customers by ID
- D: To map customer IDs to their names
View Answer
A
Q248: How do you retrieve a customer's name from a Dictionary<int, Customer>?
- A: customer.Name
- B: dictionary.GetValue(customer.ID)
- C: dictionary[customer.ID].Name
- D: dictionary.Values.Name
View Answer
C
Q249: What is an anonymous method used for in C#?
- A: Declaring a new class
- B: Handling events and delegates
- C: Creating a new type of loop
- D: Defining a static method
View Answer
B
Q250: How do you attach an anonymous method to an event in C#?
- A: Using the new keyword
- B: Using the delegate keyword
- C: Declaring a named method
- D: Using a lambda expression
View Answer
B