C# MCQ form
C# MCQ form
1. Correct way to assign values to variable ‘c’ when int a=12, float b=3.5, int c;
a) c = a + b;
b) c = a + int(float(b));
c) c = a + convert.ToInt32(b);
d) c = int(a + b);
1. int a,b;
2. a = (b = 10) + 5;
a) b = 10, a = 5
b) b = 15, a = 5
c) a = 15, b = 10
d) a = 10, b = 10
Answers:
1. b
2. a
3. b
4. d
5. c
6. d
7. a
8. b
9. c
10. c
Answers:
1. b
2. c
3. a
4. b
5. d
6. b
7. b
8. a
9. b
10. a
Answers:
1. b
2. c
3. b
4. d
5. d
6. c
7. a
8. a
9. a
10. a
1. What is the purpose of the InitializeComponent() method in a C# Windows
Form? a. Initializes the form's components and controls
b. Closes the form
c. Sets the form's title
d. Handles form resizing
2. Which event is triggered when a button is clicked in a Windows Form? a.
ButtonClick
b. ClickEvent
c. MouseClick
d. OnClick
3. In C# Windows Forms, what is the default layout manager for controls? a.
FlowLayout
b. GridLayout
c. StackLayout
d. FlowLayoutPanel
4. What is the purpose of the MessageBox class in C#? a. Display text in the console
window
b. Display a message box with buttons and options
c. Manage file input and output
d. Handle mouse events
5. Which property of a TextBox control is used to get or set the text content
programmatically? a. Value
b. Text
c. Content
d. Input
6. Which event is triggered when a user presses a key while a control has focus
in a Windows Form? a. KeyDown
b. KeyPress
c. KeyUp
d. KeyAction
7. What is the purpose of the this keyword in the context of a Windows Form
class? a. Refers to the current instance of the class
b. Represents a static reference to the class
c. Points to the base class instance
d. Refers to the parent form
8. Which of the following is not a valid dialog box in C# Windows Forms? a.
OpenFileDialog
b. ColorDialog
c. FontDialog
d. MessageDialog
9. What is the role of the Application.Run() method in a C# Windows Forms
application? a. Terminates the application
b. Starts the application's main loop
c. Displays a splash screen
d. Closes all open forms
10. Which control is used to display a list of items in a drop-down menu in C#
Windows Forms? a. ComboBox
b. ListBox
c. ListView
d. DropDownBox
Answers:
1. a
2. d
3. b
4. b
5. b
6. a
7. a
8. d
9. b
10. a