Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
15 views

What is event-driven programming A) A programming paradigm where execution is determined by a sequence of loops. B) A programming paradigm where execution is determined by user events, sensor outp

The document provides a comprehensive overview of event-driven programming, including its definition, key components like event handlers and event loops, and examples of events. It also covers C# programming concepts, the .NET Framework, and Visual Studio functionalities, such as GUI controls and naming conventions. Additionally, it addresses common programming questions and the correct usage of various C# features.

Uploaded by

Marc Franz Aseo
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)
15 views

What is event-driven programming A) A programming paradigm where execution is determined by a sequence of loops. B) A programming paradigm where execution is determined by user events, sensor outp

The document provides a comprehensive overview of event-driven programming, including its definition, key components like event handlers and event loops, and examples of events. It also covers C# programming concepts, the .NET Framework, and Visual Studio functionalities, such as GUI controls and naming conventions. Additionally, it addresses common programming questions and the correct usage of various C# features.

Uploaded by

Marc Franz Aseo
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/ 224

What is event-driven programming?

A) A programming paradigm where execution is determined by a sequence of


loops.
B) A programming paradigm where execution is determined by user events, sensor
outputs, or message passing.
C) A programming paradigm that only runs scripts in the background without user
interaction.
D) A programming paradigm that executes code in a fixed order without external
inputs.
B) A programming paradigm where execution is determined by user events, sensor
outputs, or message passing.
Which of the following is NOT an example of an event in event-driven
programming?
A) Mouse click
B) Key press
C) Program execution in a fixed sequence
D) Window resize
C) Program execution in a fixed sequence
What is an event handler?
A) A block of code that runs automatically without any user input
B) A block of code that runs in response to an event
C) A function that continuously checks for errors in a program
D) A tool used to compile C# code
B) A block of code that runs in response to an event
What is the role of an event loop in event-driven programming?
A) It listens for events and triggers the appropriate event handler when an event
occurs.
B) It executes all events at the same time without waiting.
C) It processes only one event and then stops.
D) It prevents users from interacting with the application.
A) It listens for events and triggers the appropriate event handler when an
event occurs.
What happens when multiple events occur in a short period of time?
A) They are processed randomly without any order.
B) They are ignored if too many events occur.
C) They are placed in an event queue and processed in order.
D) Only the first event is processed, and the rest are discarded.
C) They are placed in an event queue and processed in order.
Which of the following is NOT a type of GUI event?
A) Mouse click
B) Key press
C) Variable declaration
D) Window resize
C) Variable declaration
Who developed the C# programming language?
A) James Gosling
B) Bjarne Stroustrup
C) Anders Hejlsberg
D) Guido van Rossum
C) Anders Hejlsberg
What is the purpose of the .NET Framework?
A) It is a framework used to develop software applications.
B) It is an operating system for C# programs.
C) It is a hardware component required to run C#.
D) It is a database management system.
A) It is a framework used to develop software applications
Which of the following is NOT a type of C# application?
A) Window applications
B) Web applications
C) Mobile applications
D) Hardware driver applications
D) Hardware driver applications
Which part of Visual Studio displays the project’s files and structure?
A) Menu
B) Solution Explorer
C) Toolbox
D) Output Window
B) Solution Explorer
Which of the following is NOT a basic concept in C# programming?
A) Datatypes
B) Variables
C) Operators
D) Web Hosting
D) Web Hosting
What will the following algebraic expression evaluate?
ax+bax−b\frac{ax + b}{ax - b}ax−bax+b​
A) The sum of aaa and bbb
B) The ratio of two linear expressions
C) The product of aaa and xxx
D) The difference of axaxax and bbb
B) The ratio of two linear expressions
Which of the following is an example of an event in event-driven programming?
A) Declaring a variable
B) Assigning a value to a variable
C) A mouse click on a button
D) Writing a comment in code
C) A mouse click on a button
What is the purpose of an event queue?
A) To store and process multiple events in order
B) To ignore unnecessary events
C) To execute events in a random sequence
D) To prevent the program from responding to user input
A) To store and process multiple events in order
Which of the following is not common types of GUI events? (Select all that apply)
A) Mouse move, click, or drag
B) Key press or release
C) Touchscreen tap or drag
D) Creating a new variable
D) Creating a new variable
What does the event loop do in event-driven programming?
A) Stops the program from running unless an error occurs
B) Continuously listens for events and triggers event handlers when needed
C) Deletes events that are not processed quickly
D) Runs all code in a sequential order without user interaction
B) Continuously listens for events and triggers event handlers when needed
Which of the following is NOT a part of Visual Studio?
A) Solution Explorer
B) Toolbox
C) Event Queue
D) Output Window
D) Output Window
Which of the following best describes C#?
A) A simple, modern, object-oriented programming language
B) A low-level assembly language
C) A markup language like HTML
D) A database query language
A) A simple, modern, object-oriented programming language
Which of the following is NOT a type of C# application?
A) Web applications
B) Database applications
C) Hardware firmware applications
D) Distributed applications
C) Hardware firmware applications
Which component of the .NET Framework is responsible for executing C#
programs?
A) Common Language Runtime (CLR)
B) Solution Explorer
C) Toolbox
D) Event Queue
A) Common Language Runtime (CLR)
Which of the following programming languages is NOT supported by the .NET
Framework?
A) C#
B) Python
C) JavaScript
D) Java
D) Java
Which of the following is an example of an event handler?
A) A function that executes when a button is clicked
B) A loop that runs indefinitely
C) A variable storing a number
D) A comment in a code file
A) A function that executes when a button is clicked
Which of the following statements about .NET Framework is TRUE?
A) It only supports the C# programming language
B) It provides a large number of class libraries known as FCL (Framework Class
Library)
C) It is only used for web applications
D) It cannot run on Windows operating systems
B) It provides a large number of class libraries known as FCL (Framework Class
Library)
What is the purpose of the Toolbox in Visual Studio?
A) It displays the project's file structure
B) It provides a set of controls (buttons, textboxes, etc.) for GUI development
C) It runs and debugs the application
D) It manages project dependencies
B) It provides a set of controls (buttons, textboxes, etc.) for GUI development
What is the primary use of the Output Window in Visual Studio?
A) To display error messages, debugging information, and program output
B) To edit the graphical user interface (GUI)
C) To list all project files and folders
D) To write and modify source code
A) To display error messages, debugging information, and program output
Which of the following best describes the Designer View in Visual Studio?
A) A section where you write raw C# code
B) A visual interface for designing the GUI of an application
C) A debugging tool for identifying runtime errors
D) A command-line interface for compiling code
B) A visual interface for designing the GUI of an application
In C#, what is the correct way to declare a variable that stores an integer?
A) int number = "10";
B) int number = 10;
C) string number = 10;
D) float number = 10;
B) int number = 10;
Which of the following operators is used for division in C#?
A) *
B) +
C) /
D) %
C) /
What will be the result of the following C# expression?
csharp

int x = 5;
int y = 2;
double result = x / y;
Console.WriteLine(result);

A) 2.5
B) 2
C) Error
D) 5/2
B) 2
Which of the following correctly takes user input in a C# console application?
A) Console.WriteLine();
B) Console.ReadLine();
C) int x = 10;
D) Console.Output();
B) Console.ReadLine();
Which of the following statements about event-driven programming is FALSE?
A) It is based on user interactions like mouse clicks and key presses.
B) It requires event handlers to respond to events.
C) The program runs all code sequentially, ignoring user inputs.
D) It is commonly used in GUI applications.
C) The program runs all code sequentially, ignoring user inputs.
Which of the following is an example of an event source?
A) A variable storing a number
B) A button in a GUI application
C) A comment in code
D) A loop that runs indefinitely
B) A button in a GUI application
Which programming paradigm does event-driven programming belong to?
A) Object-oriented programming
B) Functional programming
C) Procedural programming
D) Reactive programming
A) Object-oriented programming
In C#, which operator is used to get the remainder of a division?
A) /
B) %
C) *
D) //
B) %
What is the .NET Framework primarily used for?
A) Creating mobile applications only
B) Developing Windows, Web, and Web Service applications
C) Writing low-level assembly code
D) Managing hardware devices
B) Developing Windows, Web, and Web Service applications
Which of the following languages can be used with the .NET Framework?
A) C#
B) Visual Basic
C) COBOL
D) All of the above
D) All of the above
What is the first method that runs when a C# console application starts?
A) Start()
B) Execute()
C) Main()
D) Run()
C) Main()
What is the purpose of Console.WriteLine() in C#?
A) To read input from the user
B) To display output on the console
C) To pause program execution
D) To create a new class
B) To display output on the console
Which C# data type is used to store decimal numbers?
A) int
B) string
C) double
D) bool
C) double
What will happen if you try to run a C# application without the .NET Framework
installed on the computer?
A) It will run normally
B) It will display an error message
C) It will convert to another programming language
D) It will run but with limited features
B) It will display an error message
Which C# data type is used to store true or false values?
A) int
B) string
C) bool
D) double
C) bool
What does the Console.ReadLine() method do in C#?
A) Prints a message to the console
B) Reads input from the user
C) Pauses the program indefinitely
D) Closes the console application
B) Reads input from the user
Which part of a C# program must match the file name?
A) Method name
B) Class name
C) Namespace name
D) Variable name
B) Class name
Which of the following statements is TRUE about C#?
A) C# is not an object-oriented programming language
B) C# can only be used for web applications
C) C# runs on the .NET Framework
D) C# does not support console applications
C) C# runs on the .NET Framework
What is the starting point of every C# console application?
A) Console.WriteLine()
B) Main() method
C) namespace declaration
D) using statement
B) Main() method
What is the purpose of the using statement in C#?
A) It defines the starting point of the program
B) It is used to include namespaces in a program
C) It declares a variable
D) It stops the program from running
B) It is used to include namespaces in a program
What will happen if you don't include Console.ReadKey() at the end of a console
application?
A) The program will not compile
B) The program will crash
C) The console window will close immediately after execution
D) The program will run indefinitely
C) The console window will close immediately after execution
Which of the following is NOT a valid C# data type?
A) int
B) float
C) text
D) bool
C) text
What is the correct way to declare a boolean variable in C#?
A) boolean isTrue = true;
B) bool isTrue = true;
C) bool isTrue = "true";
D) Boolean isTrue = "true";
B) bool isTrue = true;
Which keyword is used to define a class in C#?
A) define
B) struct
C) class
D) object
C) class
Which of the following is NOT a part of the .NET Framework?
A) Common Language Runtime (CLR)
B) Framework Class Library (FCL)
C) Java Virtual Machine (JVM)
D) .NET Compiler
C) Java Virtual Machine (JVM)
What will be the output of the following C# program?

int x = 10;
x += 5;
Console.WriteLine(x);

A) 10
B) 5
C) 15
D) Error
C) 15
Which keyword is used in C# to accept user input from the console?
A) Console.WriteLine()
B) Console.ReadLine()
C) Console.ReadKey()
D) Console.Write()
B) Console.ReadLine()
What will be the output of the following C# code?

int a = 5, b = 2;
double result = (double)a / b;
Console.WriteLine(result);

A) 2
B) 2.5
C) 2.0
D) Error
B) 2.5
What will be the output of the following C# code?
int num = 10;
num++;
Console.WriteLine(num);
A) 9
B) 10
C) 11
D) Error
C) 11
Which of the following is NOT a valid C# variable name?
A) _studentName
B) 2ndScore
C) total_amount
D) firstName
B) 2ndScore
What will be the value of result after executing the following code?

int a = 5;
int b = 2;
double result = a / b;
Console.WriteLine(result);

A) 2.5
B) 2
C) 2.0
D) Error
B) 2
What does GUI stand for?
a) General User Interaction
b) Graphical User Interface
c) General Unified Interface
d) Graphical Utility Input
b) Graphical User Interface
What is the main purpose of a GUI?
a) To allow users to interact with a program visually
b) To speed up the computer’s processing power
c) To write code more efficiently
d) To store large amounts of data
a) To allow users to interact with a program visually
Which C# framework is used to create graphical user interfaces in Visual Studio?
a) Windows Console Application
b) ASP.NET Core
c) Windows Forms
d) Java Swing
c) Windows Forms
Which of the following is NOT a GUI control in C#?
a) Label
b) TextBox
c) Timer
d) Console
d) Console
What is the purpose of the Toolbox in Visual Studio?
a) To store project files
b) To provide a collection of GUI controls and components
c) To debug C# applications
d) To execute C# code
b) To provide a collection of GUI controls and components
Where is the Toolbox located in Visual Studio by default?
a) Bottom-right corner
b) Top menu bar
c) Left-hand side
d) Middle of the screen
c) Left-hand side
How do you add a component from the Toolbox to a form?
a) Click on the component and press Enter
b) Click and drag the component onto the form
c) Right-click and select "Add to Form"
d) Type the component name manually in the code
b) Click and drag the component onto the form
Which of the following controls is used to display text but cannot be edited by the
user?
a) TextBox
b) Label
c) ComboBox
d) ListBox
b) Label
What property should be modified to change the text displayed on a Label
control?
a) Text
b) Name
c) Font
d) Visible
a) Text
What is the naming convention prefix for a Button control?
a) txt
b) lbl
c) btn
d) box
c) btn
What is the correct way to name a TextBox used for entering a username?
a) lblUsername
b) txtEnterName
c) btnUser
d) boxUsername
b) txtEnterName
What happens when you double-click a button in the design view of Visual Studio?
a) The button is removed from the form
b) The properties window opens
c) The event handler for the button’s Click event is created in the code
d) A new button is added to the form
c) The event handler for the button’s Click event is created in the code
What is an event handler in C#?
a) A property that determines how a button looks
b) A method that runs when a specific event occurs, such as clicking a button
c) A class that stores all the controls in a GUI
d) A special setting in the properties window
b) A method that runs when a specific event occurs, such as clicking a button
Which of the following is an example of an event?
a) Setting a button’s background color
b) Clicking a button
c) Writing code in the editor
d) Changing the font of a Label
b) Clicking a button
What event is triggered when a user types in a TextBox?
a) Click
b) TextChanged
c) Enter
d) Load
b) TextChanged
Which property should be set to True to make a TextBox behave like a password
field?
a) HideText
b) PasswordMode
c) UseSystemPasswordChar
d) MaskInput
c) UseSystemPasswordChar
How do you retrieve the text entered in a TextBox named txtUserName?
a) string userName = GetText(txtUserName);
b) string userName = txtUserName.Text;
c) string userName = InputText(txtUserName);
d) string userName = txtUserName.Value;
b) string userName = txtUserName.Text;
What will the following line of code do?

txtUserName.Text = "";

a) Display "Hello!" in the TextBox


b) Make the TextBox invisible
c) Clear the text inside the TextBox
d) Delete the TextBox
c) Clear the text inside the TextBox
How can you create and show a second form named Form2 from Form1?
a) Form2 frm2 = new Form2(); frm2.Show();
b) Create(Form2);
c) frm2.Display();
d) Form2.Open();
a) Form2 frm2 = new Form2(); frm2.Show();
What happens when the user clicks "Go" on Form1 in a multiple-form program?
a) Form1 is hidden, and Form2 is displayed
b) Form1 closes, and Form2 is deleted
c) A message box appears
d) The program stops running
a) Form1 is hidden, and Form2 is displayed
What happens when the user enters "admin" as the username and "1234" as the
password in Form2?
a) Form1 is hidden
b) Form2 is displayed again
c) Form2 is hidden, and Form1 is displayed
d) The text in the textboxes is cleared
c) Form2 is hidden, and Form1 is displayed
What does the following code do?

MessageBox.Show("Thank you!");

a) Closes the application


b) Displays a message box with "Thank you!"
c) Changes the form title to "Thank you!"
d) Deletes all text in the form
b) Displays a message box with "Thank you!"
What is the purpose of MessageBoxButtons.YesNo in a MessageBox?
a) It displays Yes and No buttons in the MessageBox
b) It closes the MessageBox automatically
c) It forces the user to enter a Yes or No value in a TextBox
d) It restarts the application
a) It displays Yes and No buttons in the MessageBox
What does the following code do?

DialogResult result = MessageBox.Show("Do you want to quit?", "Exit",


MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
Application.Exit();
}

a) Closes the form immediately


b) Shows a message box asking the user if they want to quit, then exits if they
select "Yes"
c) Restarts the application
d) Shows a message box but does nothing else
b) Shows a message box asking the user if they want to quit, then exits if they
select "Yes"
What is the primary purpose of restricting user input in a C# Windows Forms
application?
a) To improve the application's performance
b) To prevent users from entering invalid or unwanted data
c) To make the application look more appealing
d) To reduce memory usage
b) To prevent users from entering invalid or unwanted data
What event is commonly used for validating user input when moving focus
between controls?
a) TextChanged
b) Validating
c) MouseClick
d) Load
b) Validating
What happens when the CancelEventArgs.Cancel property is set to true in a
Validating event?

a) The application closes automatically


b) The focus remains on the current control
c) The invalid input is automatically corrected
d) The form refreshes itself
b) The focus remains on the current control
Which Windows Forms control is used to visually indicate an error in user input?
a) MessageBox
b) ErrorProvider
c) StatusBar
d) ToolTip
b) ErrorProvider
Where can you find the "Validating" event for a TextBox in Visual Studio?
a) Under the Properties window > Events tab
b) In the Solution Explorer
c) In the Toolbox
d) Inside the Program.cs file
a) Under the Properties window > Events tab
What is the primary purpose of the char structure in C#?
a) To perform mathematical operations
b) To store and manipulate individual characters
c) To create graphical user interfaces
d) To define classes and objects
b) To store and manipulate individual characters
Which of the following methods is used to check if a character is a digit?
a) char.IsLetter()
b) char.IsDigit()
c) char.IsUpper()
d) char.IsLower()
b) char.IsDigit()
What does char.IsLetterOrDigit() check for?
a) If a character is a special symbol
b) If a character is a whitespace
c) If a character is a letter or a digit
d) If a character is a separator
c) If a character is a letter or a digit
Which method converts a string to a character?
a) char.Parse()
b) char.Convert()
c) char.ToChar()
d) char.StringToChar()
a) char.Parse()
What is the function of the KeyPress event in a TextBox control?
a) It captures and evaluates keyboard input before it is displayed
b) It prevents all user input from being entered
c) It runs automatically when the form loads
d) It triggers an error message whenever a key is pressed
a) It captures and evaluates keyboard input before it is displayed
How would you restrict a TextBox to accept only letters?
a) Using char.IsDigit()
b) Using char.IsLetter() in a KeyPress event
c) Setting TextBox.ReadOnly = true
d) Removing the TextBox from the form
b) Using char.IsLetter() in a KeyPress event
Which function would you use to restrict input to only numbers?
a) char.IsLetter()
b) char.IsDigit()
c) char.IsSeparator()
d) char.IsSymbol()
b) char.IsDigit()
What method allows both letters and numbers but restricts special characters?
a) char.IsDigit()
b) char.IsLetterOrDigit()
c) char.IsSymbol()
d) char.IsPunctuation()
b) char.IsLetterOrDigit()
If you need to allow only special characters in a TextBox, what approach should
you take?
a) Use char.IsLetterOrDigit() and check for a negative match
b) Use char.IsLetter()
c) Use char.IsDigit()
d) Use char.ToString()
a) Use char.IsLetterOrDigit() and check for a negative match
What happens when you set UseSystemPasswordChar = true for a TextBox?
a) It restricts all input except numbers
b) It converts all text into a password-protected format (e.g., "●●●")
c) It allows only uppercase letters
d) It changes the font of the TextBox
b) It converts all text into a password-protected format (e.g., "●●●")
How would you allow only numbers with decimals in a TextBox?
a) Use char.IsLetter()
b) Check for char.IsDigit() and allow . (decimal point)
c) Use char.IsSeparator()
d) Set TextBox.ReadOnly = true
b) Check for char.IsDigit() and allow . (decimal point)
What property must be set to true for validation to trigger when moving between
controls?
a) Enabled
b) CausesValidation
c) ReadOnly
d) Multiline
b) CausesValidation
What happens if a user enters invalid data and the validation fails?
a) The input is automatically corrected
b) The application crashes
c) The user is notified, and the focus remains on the invalid control
d) The invalid input is ignored, and the form continues running
c) The user is notified, and the focus remains on the invalid control
Which key is typically allowed when restricting user input but still permitting
corrections?
a) Enter
b) Backspace
c) Spacebar
d) Tab
b) Backspace
How do you show an error message using an ErrorProvider in Windows Forms?
a) errorProvider1.SetError(textBox1, "Invalid Input");
b) MessageBox.Show("Invalid Input");
c) Console.WriteLine("Invalid Input");
d) textBox1.Text = "Invalid Input";
a) errorProvider1.SetError(textBox1, "Invalid Input");
What method should be used to allow both letters and control characters (like
Backspace)?
a) char.IsDigit()
b) char.IsLetterOrDigit() and check for control keys
c) char.IsUpper()
d) char.Parse()
b) char.IsLetterOrDigit() and check for control keys
If a TextBox should allow only numbers and one decimal point, what additional
check should be performed?
a) Ensure the decimal point . appears only once
b) Allow multiple decimal points
c) Replace . with ,
d) Convert all numbers to letters
a) Ensure the decimal point . appears only once
What does setting TextBox.CausesValidation = false do?
a) Disables input in the TextBox
b) Prevents the Validating event from triggering when moving focus
c) Enables validation for the TextBox
d) Deletes the input data
b) Prevents the Validating event from triggering when moving focus
What is the correct way to check if a character is uppercase?
a) char.IsUpper()
b) char.IsLower()
c) char.IsDigit()
d) char.IsSeparator()
a) char.IsUpper()
What should be the first step when implementing input validation in a Windows
Forms application?
a) Create a Windows Forms application
b) Use an ErrorProvider
c) Set TextBox.ReadOnly = true
d) Prevent users from entering data
a) Create a Windows Forms application

You might also like