0% found this document useful (0 votes)
37 views7 pages

Pdfs_Question Bank - Visual C# - 100 Questions (2)

The document is a question bank for Stage 5 Programming in Visual C#, consisting of 100 questions divided into multiple-choice, true/false, short answer, and fill-in-the-blank formats. It covers various topics related to C# programming, including user interface controls, syntax, and properties. The questions aim to assess knowledge of C# and its application in building different types of software.

Uploaded by

abasazjy
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)
37 views7 pages

Pdfs_Question Bank - Visual C# - 100 Questions (2)

The document is a question bank for Stage 5 Programming in Visual C#, consisting of 100 questions divided into multiple-choice, true/false, short answer, and fill-in-the-blank formats. It covers various topics related to C# programming, including user interface controls, syntax, and properties. The questions aim to assess knowledge of C# and its application in building different types of software.

Uploaded by

abasazjy
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/ 7

Question Bank - Stage 5 Programming - Visual C# - 100 Questions

Multiple Choice (50 Questions)


1. C# is a modern, general-purpose, object-oriented programming language developed by Microsoft as part
of its:
A) .NET framework
B) Flutter
C) Java Development Kit (JDK)
D) All of them
2. C# is designed for building a wide range of applications, including:
A) web
B) mobile
C) desktop
D) All of them
3. With the release of .NET 8 and .NET 9, is C# considered a cross-platform language?
A) No, C# is still limited to Windows only.
B) Yes, C# is cross-platform, supporting Windows, Linux, and macOS.
C) No, C# is only cross-platform for mobile applications.
D) Yes, but only for web applications.
4. For which one of these programming languages is the following statement true?
"It is a modern, general-purpose, object-oriented programming language developed by Microsoft as part
of its .NET framework."
A) Python
B) Flutter
C) C#
D) Java
5. Is a type of user interface that allows users to interact with software through graphical elements such as
icons, buttons, windows, and menus, rather than text-based commands?
A) CLI
B) GUI
C) API
D) .NET
6. Which of the following is one of the simplest ways to create desktop applications on Windows?
A) Windows Defender
B) Windows Forms
C) Angular
D) None of them
7. Which of the following statements is true about Windows Forms?
A) Windows Forms is a web development framework included in the .NET Framework.
B) Windows Forms is a machine learning library included in the .NET Framework.
C) Windows Forms is a graphical (GUI) class library included in the .NET Framework.
D) Windows Forms is a database management system included in the .NET Framework.
8. Which one of the following is not part of the Visual Studio Interface?
A) The Ribbon
B) The Solution Explorer
C) The Toybox
D) None of them
9. What is the purpose of the Toolbox in Visual Studio?
A) The Toolbox window displays controls that you can add to Visual Studio projects.
B) The Toolbox window is used to write and compile code in Visual Studio.
C) The Toolbox window is used for managing project files and folders in Visual Studio.
D) The Toolbox window is used to debug code in Visual Studio.

1
10. Which one of the following contains a brief description of each control and it events in Visual Studio?
A) The Solution Explorer B) Properties C) File D) New Project
11. Which of the following is a common use case for labels when creating Windows applications?
A) To display dynamic charts and graphs.
B) To show static text or descriptions, such as instructions or titles.
C) To collect user input data.
D) To process and validate form fields.

12. Which of the following is a dynamic use case for labels in Windows applications?
A) To show real-time information such as the current time or date.
B) To display a list of available options.
C) To create user-input validation rules.
D) To provide a link to external websites.

13. What is one of the most common uses for TextBoxes in Windows applications?
A) To allow users to upload files.
B) To allow users to enter text, such as names, addresses, or search queries.
C) To display static labels or instructions.
D) To show images or graphics.
14. What is the primary purpose of Buttons in Windows applications?
A) To display static text on a form.
B) To trigger actions and make the application interactive.
C) To organize content within the window.
D) To show real-time data updates.
15. Which one of the following controls is best to be used to submit user input or data to a server or
database?
A) Label B) RadioButton C) CheckBox D) Button
16. Which one of the following codes is the right way to modify the displayed text in a Label?
A) label1.Name = “Bold”;
B) label1.DisplayText = “Bold”;
C) label1.Text = “Bold”;
D) label1 = “Bold”;
17. Which one of the following is true if I want to convert a normal textbox into a password field?
A) textbox1.Text = “Password”;
B) textbox1.PasswordChar = ‘*’;
C) textbox1.UseSystemPasswordChar = false;
D) textbox1.MaxLength = 8;
18. Which one of the following codes is the right way to show a messagebox?
A) MessageBox.Show("Current Form is " + this.Text);
B) MessageBox.Show = “Welcome”;
C) Message.Show(“Stage 5 Programming”);
D) All of them
19. Which one of the following is the right way to change a Label’s displayed text to Bold?
A) title_lbl.Font = new Font(FontStyle.Bold);
B) title_lbl.Font = new Font(title_lbl.Font, FontStyle.Bold);
C) title_lbl.Font = Font(title_lbl.Font, FontStyle.Bold);
D) title_lbl.Font = Bold;
20. Which one of the following is the right way to empty a textbox?
A) input_txt.Clear();
B) input_txt.Text = "";

2
C) Both ways are true
D) None of them
21. Which one of the following codes changes the color of the Form? A) Form.Color = Black;
B) Form.BackColor = White; C) this.BackColor = Color.Gray; D) None of them
22. What is the correct way to write a single line of comment in C#?
A) \\ this way B) //this way C) ##this way D) All of them
23. What is the primary purpose of a radio button in a user interface?
A) Allowing the selection of multiple options
B) Providing a toggle for enabling or disabling a feature
C) Enabling the user to select a single option from a group
D) Displaying error messages
24. In which scenario is a ComboBox most effectively used?
A) Selecting multiple filter criteria at once
B) Choosing a predefined option, such as a country or language
C) Toggling a feature on or off
D) Displaying a progress bar for loading data
25. What does the line comboBox1.SelectedIndex = 0; achieve in the code?
A) Sets the ComboBox to allow custom input.
B) Adds a new item to the ComboBox.
C) Sets the default selected item to the first item in the list.
D) Changes the text color of the ComboBox.
26. How does the line comboBox1.DropDownStyle = ComboBoxStyle.DropDownList; modify the
behaviour of the ComboBox?
A) Allows users to edit the text in the ComboBox.
B) Makes the ComboBox display only predefined items without allowing editing.
C) Enables users to select multiple items at once.
D) Changes the appearance of the ComboBox to a read-only text box.
27. Which method is used in the code to add items to the ComboBox?
A) AddItem() B) Append() C) Items.Add() D) Insert()

28. Which one of the following statements about the ComboBox code is incorrect?
A) comboBox1.Items.Add("Lebanon"); //adds an item named "Lebanon" to the ComboBox.
B) comboBox1.SelectedIndex = 0; //sets the default selected item to the first item.
C) comboBox1.DropDownStyle = ComboBoxStyle.DropDownList; //allows the ComboBox to be editable.
D) comboBox1.Font = new Font("Arial", 10); //changes the font of the ComboBox items to Arial
29. Which of the following is a key feature of a ListBox?
A) It allows only single-item selection.
B) It enables users to select multiple items from a list.
C) It is always editable like a text box.
D) It cannot dynamically add or remove items.
30. What makes a ListBox different from a ComboBox?
A) A ListBox only displays text, while a ComboBox displays icons.
B) A ListBox allows multiple items to be selected, while a ComboBox typically allows only one.
C) A ListBox cannot be dynamically updated, while a ComboBox can.
D) A ListBox always requires user input, while a ComboBox does not.
31. What does the line listBox1.Items.Add("Baban"); do in the code?
A) Removes an item named "Iraq" from the ListBox.
B) Selects "Iraq" as the default item in the ListBox.
C) Adds an item named "Baban" to the ListBox.
D) Changes the font style of the ListBox.
3
32. What happens if listBox1.SelectionMode = SelectionMode.None; is set?
A) Users can select only one item.
B) Users can select multiple items.
C) No items can be selected by the user.
D) The first item is automatically selected by default.
33. What does listBox1.SelectedIndex = 0; achieve in the code?
A) Sets the default selected item to the first item in the list.
B) Removes the first item from the ListBox.
C) Disables selection for the first item in the ListBox.
D) None of them
34. What is the correct way to declare a variable in C#?
A) int num = 5;
B) num = 5 int;
C) int = num 5;
D) 5 = num int;
35. Which of the following statements about C# arrays is correct?
A) An array in C# can store elements of different types.
B) The size of an array in C# is fixed after its declaration.
C) C# arrays are dynamically sized.
D) C# arrays must contain exactly 10 elements.
36. In C#, which of the following is the correct way to declare an array of integers with 5 elements?
A) int[] arr = {1, 2, 3, 4, 5};
B) int arr[5] = {1, 2, 3, 4, 5};
C) int arr[] = new int[5]{1, 2, 3, 4, 5};
D) int arr[] = {1, 2, 3, 4, 5};
37. What is the default value of an uninitialized int variable in C#?
A) 0 B) null C) undefined D) 0.0

38. What type of value can the PasswordChar property of a TextBox control accept in C#?
A) Any single Unicode character
B) Only the asterisk (*)
C) A string of characters
D) A boolean value
39. What happens when the following line of code is executed input_txt.PasswordChar = '\0';?
A) It makes the password input visible by removing the masking character.
B) It sets the TextBox background color to transparent.
C) It sets the font size of the TextBox text to zero.
D) It disables password masking completely.
40. Which of the following is a valid value for the StartPosition property in Windows Forms?
A) TopLeft
B) Manual
C) CenterScreen
D) AutoPosition
41. What is the main difference between the BackColor and ForeColor properties in Windows Forms
controls?
A) BackColor sets the color of the text, and ForeColor sets the background color.
B) BackColor sets the background color of the control, and ForeColor sets the color of the text.
C) BackColor sets the color of the form's border, and ForeColor sets the color of the title.
D) BackColor is used for controls with images, and ForeColor is used for buttons.
42. The only true option is: What does the MaxLength property of a TextBox control do in C#?

4
A) Defines the maximum font size
B) Limits the number of characters the user can enter
C) Limits the number of lines the user can input
D) Sets the maximum width of the TextBox
43. The only true option is: What does the TextAlign property of a TextBox control do in C#?
A) Aligns the text based on the current font size
B) Specifies the text color
C) Determines the alignment of the text within the TextBox
D) Sets the text style to bold or italic
44. In a form where the user is asked to select their gender using radio buttons for "Male" and "Female," what
do the radio buttons allow the user to do?
A) Select multiple genders
B) Select only one gender
C) Enter a custom gender
D) Toggle between gender options
45. In a survey form, the user is asked to select which programming languages they are familiar with (C#,
Java, Python, JavaScript). Which control should be used to allow the user to select multiple programming
languages?
A) Radio buttons
B) Textbox
C) Checkbox
D) Dropdown list
46. Which control property in Windows Forms is used to change the mouse pointer when it hovers over the
control?
A) Pointer
B) Cursor
C) HoverStyle
D) MouseStyle
47. What does the Solution Explorer in Visual Studio display?
A) The output of the program
B) The hierarchy of a C# program's files and resources
C) The list of all installed extensions
D) The properties of the selected control
48. Which one of the following is not a standard Windows Forms control?
A) TextBox
B) ComboBox
C) ListView
D) ToolBox
49. In Visual Studio, which tab in the Properties window is used to associate event handlers with control
events and view their available actions?
A) Events
B) Behaviour
C) Actions
D) Methods
50. Which of the following is the correct syntax for an if-else statement in C#?
A) if (x > 10) { Console.WriteLine("Greater"); } else { Console.WriteLine("Smaller"); }
B) if x > 10 { Console.WriteLine("Greater"); } else Console.WriteLine("Smaller");
C) if (x > 10): { Console.WriteLine("Greater"); } else { Console.WriteLine("Smaller"); }
D) if x > 10 then { Console.WriteLine("Greater"); } else { Console.WriteLine("Smaller"); }

5
True/False, Short Answer and Blank (50 Questions)

A. Write the name of the control that is most fit for each given scenario:
1. To show static text or descriptions Label
2. To collect a single line of text input from the user textbox
3. To allow the user to choose between multiple options, but only one can be selected at a time radioButton
4. To allow the user to select multiple options from a list CheckBox
5. To submit user input or data to a server or database Button
6. To display a list of items from which the user can select one ComboBox
7. To collect a single line of text input, but with the option to hide the input (password) TextBox (with
8. To toggle between two options, such as "Yes" or "No" radioButton PasswordChar set)
9. For drop-down selection ComboBox
10. To display a list of items where the user can select only one option at a time ComboBox

B. The following codes are false, write the corrected code:


1. combobox1.SelectedIndex = “1”; combobox1.SelectedIndex = 1;
2. password_txt.PasswordChar = “*”; password_txt.PasswordChar = '*';
3. if(x=5) { button1.ForeColor = Color.Red; }
if (x == 5) { button1.ForeColor = Color.Red; }
4. MessageBox.Show = “Hello World”; MessageBox.Show("Hello World");
5. label1.Text = 12345; label1.Text = "12345";
6. input_txt.Text = ‘’; input_txt.Text = "";
7. if (true) { This.Text = "My Form"; } if (true) { this.Text = "My Form"; }
8. if (darkBG_radio.Checked == Checked) { input_txt.BackColor = Color.Black; }
9. char PasswordChar = "*"; char PasswordChar = '*';
10. this.Text = items_combobox.SelectedItem; this.Text = items_combobox.SelectedItem.ToString();
8 - if (darkBG_radio.Checked) { input_txt.BackColor = Color.Black; }
C. Write 3 use cases for each of the following controls:
1. Label Display static text | Show messages | Display dynamic output.
2. CheckBox Select multiple options | Enable/disable settings | Accept terms.
3. Button Submit forms | Trigger actions | Start/stop processes.
4. RadioButton Select one option | Switch modes | Choose preferences
5. TextBox Enter user input | Add comments | Search/filter data

D. Use the following image, write True or False for these statements and correct the False
statements (only the underlined):
1. There are 5 Labels in the Form. true

2. The control where the Male option is selected is a RadioButton.


False | ComboBox
3. The Sign Up is a TextBox. False | Button

4. The controls in the bottom of the Form are CheckBoxes.


False | Radiobuttons
5. The Dark option is Checked. False | Light

6
E. Use the following code, add a comment to each of the following lines (1-10) to describe
what it does:
// Triggered when the signup button is clicked
//openning bracket
// Get username input
// Get Password input
// Check if username and password are not empty

// Disable the signup button


// Close the form
// End of the if block
// End of the method
Line 6 - // Show a messageBox with the input from the username textbox and the selected item from the gender combobox

F. Fill in the following blanks with the correct property name:


1. _________
(Name) This property indicates the name used in code to identify the object.

BackColor
2. Write the name of the property that determines the background color of the component _________.

3. MaxLength
_________ This property specifies the maximum number of characters that can be entered into the
edit control.

4. RightToLeft
_________ This property indicates whether the component should draw right-to-left for RTL
languages.

5. _________
Text This property indicates the text associated with the control.

G. Fill in the following blanks with the correct word:


1. _________
Int This data type is used to store whole numbers.

2. _________
!= This operator is used in an if-else statement to check if two values are not equal.

3. _________
Boolean This data type is used to store a true or false value.
+
4. _________ This operator is used to perform addition in C#.

5. _________
Char This data type is used to store a single character.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy