0% found this document useful (0 votes)
50 views

C# MCQ form

Uploaded by

Muhammad Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

C# MCQ form

Uploaded by

Muhammad Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Mid MCQ

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);

2. How do you declare a constant in c#?


a) #define pi 6.28F
b) pi = 6.28F
c) float pi = 6.28F
d) const int x =10;

3. What will be the output of the following C# code?

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

4. When we call a constructor method among different given constructors. We


match the suitable constructor by matching the name of constructor first, then
the number and then the type of parameters to decide which constructor is to be
overloaded. The process is also known as?
a) Method overriding
b) Inheritance
c) Polymorphism
d) Encapsulation

5. how we use the using/system keyword in c#


a) for including laibraries
b) c = a + int(float(b));
c) c = a + convert.ToInt32(b);
d) c = int(a + b);

6. The data members of a class by default are?


a) protected, public
b) private, public
c) private
d) public

What is the purpose of the 'using' directive in C#?


• A. Define a namespace
• B. Declare a variable
• C. Include a library
• D. Create a loop

1. What is a Form in C#? a. A function b. A class c. A variable d. A data type


2. Which namespace is used for Windows Forms in C#? a.
System.Windows.Forms b. System.Forms c. System.Windows.Controls d.
System.GUI.Forms
3. Which method is called when a C# Windows Form is loaded? a. OnLoad() b.
Form_Load() c. LoadForm() d. Initialize()
4. Which property is used to set the title of a C# Form? a. FormTitle b. Title c.
Caption d. Text
5. What is the purpose of the DialogResult property in a C# Form? a. It sets the
form's visibility. b. It specifies the form's size. c. It indicates the result of a dialog
box. d. It defines the form's background color.
6. Which event is triggered when a button is clicked on a C# Form? a.
ButtonClick b. ClickEvent c. MouseClick d. Click
7. How can you close a C# Form programmatically? a. form.Close(); b. form.Exit();
c. form.Dispose(); d. form.Shutdown();
8. Which layout control is used for arranging controls in a table-like structure
in C# Forms? a. FlowLayoutPanel b. TableLayoutPanel c. GridLayout d. StackPanel
9. What is the purpose of the Anchor property in C# Forms? a. It defines the
form's starting position. b. It specifies the font style for controls. c. It anchors
controls to the edges of the form. d. It sets the opacity of the form.
10. Which method is called when a C# Form is closed? a. FormClosed() b.
CloseForm() c. FormClosing() d. OnClose()

Answers:

1. b
2. a
3. b
4. d
5. c
6. d
7. a
8. b
9. c
10. c

1. What is the primary purpose of a C# Windows Form? a. Data storage


b. User interface design
c. Algorithm implementation
d. Network communication
2. Which namespace is commonly used for working with Windows Forms in
C#? a. System.IO
b. System.Web
c. System.Forms
d. System.GUI
3. What is the default extension for a C# Windows Form file? a. .cs
b. .exe
c. .form
d. .dll
4. Which event is triggered when a button is clicked on a Windows Form? a.
FormLoad
b. ButtonClick
c. ClickEvent
d. ClickHandler
5. Which property is used to set the text displayed on a label control in C#? a.
TextValue
b. DisplayText
c. LabelText
d. Text
6. In C# Windows Forms, what is the purpose of the "Form Load" event? a.
Handling button clicks
b. Initializing form controls and data
c. Closing the form
d. Saving data to a database
7. Which control is used to allow users to select a date in a C# Windows Form?
a. TextBox
b. DateTimePicker
c. ComboBox
d. DatePicker
8. What is the role of the "Application.Run" method in a C# Windows Forms
application? a. Starting the application
b. Handling exceptions
c. Closing the form
d. Saving data
9. Which layout control is commonly used to arrange controls in a C#
Windows Form? a. FlowLayoutPanel
b. TableLayoutPanel
c. StackPanel
d. GridPanel
10. What does MVC stand for in the context of C# Windows Forms
development? a. Model-View-Controller
b. Microsoft Visual Components
c. Multi-View Configuration
d. Managed View Controller

Answers:

1. b
2. c
3. a
4. b
5. d
6. b
7. b
8. a
9. b
10. a

11. What is the purpose of the InitializeComponent() method in a C# Windows Form


application?

12. A. It initializes the main form of the application.

13. B. It initializes the components (controls) on the form.

14. C. It initializes the database connections.

15. D. It initializes the event handlers for button clicks.

1. What is the purpose of a C# form in Windows applications? a. Data storage


b. User interface
c. Algorithm implementation
d. File manipulation
2. Which namespace is used for working with forms in C#? a. System.IO
b. System.Data
c. System.Windows.Forms
d. System.Drawing
3. What is the default layout manager for controls on a C# form? a. GridLayout
b. FlowLayout
c. BorderLayout
d. StackLayout
4. Which event is triggered when a button is clicked in a C# form? a.
MouseClick
b. ButtonClick
c. ClickEvent
d. Click
5. What is the purpose of the InitializeComponent() method in a C# form? a.
Initialize form properties
b. Load external resources
c. Set up event handlers
d. Initialize form controls
6. Which property is used to set the title or text of a C# form? a. FormTitle
b. TitleText
c. Text
d. Caption
7. Which method is called when a C# form is about to be closed? a. FormClosing
b. FormClosed
c. CloseForm
d. Closing
8. What is the purpose of the DialogResult property in C# forms? a. Set the
form's result status
b. Set the form's visibility
c. Set the form's size
d. Set the form's position
9. Which control is used to display a message to the user in C# forms? a.
MessageBox
b. DialogBox
c. TextLabel
d. InfoBox
10. How can you add a new form to a C# project in Visual Studio? a. Right-click
on the project > Add > Form
b. File > New > Form
c. Project > New Form
d. Tools > Add Form

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

You might also like