Visual Programming MCQs with Answers
Practice important Visual Programming MCQs with answers and explanations.
Multiple Choice Questions
Q211: Which of the following is a correct way to declare a delegate in C#?
- A: delegate void myDelegate();
- B: public delegate int Comparer(object obj1, object obj2);
- C: event delegate int myDelegate();
- D: class delegate int Comparer();
View Answer
B
Q212: What is the return type of the delegate method comparefirstnames?
- A: void
- B: bool
- C: int
- D: string
View Answer
C
Q213: What is the purpose of the comparefirstnames method in the Name class?
- A: To print names
- B: To compare first names
- C: To initialize objects
- D: To sort names
View Answer
B
Q214: How do you instantiate a delegate in C#?
- A: Using the new keyword
- B: Direct assignment
- C: By reference
- D: Automatically
View Answer
A
Q215: What does the Sort method in simpledelegate class accept as a parameter?
- A: A method name
- B: An integer
- C: A delegate
- D: A string
View Answer
C
Q216: Which of the following is true about events in C#?
- A: Events can only be used with forms
- B: Events are predefined in .NET
- C: Events are always private
- D: Events can be activated by firing
View Answer
D
Q217: In C#, which keyword is used to register a delegate with an event?
- A: +=
- B: -=
- C: ==
- D: --
View Answer
A
Q218: What is the role of the onclickmeclicked method in the event example?
- A: It is a constructor
- B: It handles button clicks
- C: It creates a new event
- D: It initializes the form
View Answer
B
Q219: Which class in C# provides the basic structure for handling exceptions?
- A: System.IO
- B: System.Exception
- C: System.Delegate
- D: System.EventHandler
View Answer
B
Q220: What happens if no catch block is found for an exception in C#?
- A: The program continues
- B: The exception is ignored
- C: The program crashes
- D: The exception bubbles up the caller stack
View Answer
D