FINAL Flashcards
Which keyword is used to define a class in C#?
a) class
b) ClassName
c) void
d) public
a) class
What characters can a class name include?
a) Letters and spaces
b) Letters, digits, and underscores
c) Only letters
d) Letters, digits, underscores, and special symbols
b) Letters, digits, and underscores
A variable declaration in C# must include:
a) Only the variable type
b) Only the variable name
c) Variable name and type
d) Variable name, type, and initial value
c) Variable name and type
What is the recommended naming convention for variables?
a) PascalCase
b) UPPERCASE
c) snake_case
d) lowerCamelCase
d) lowerCamelCase
What type of method can be called without creating an object of the class?
a) Public
b) Static
c) Abstract
d) Void
b) Static
What is a Form in a Windows application?
a) A textual interface
b) A graphical element like a window or dialog
c) A type of database
d) A programming function
b) A graphical element like a window or dialog
Which namespace contains the Control class?
a) System.Windows.Forms
b) System.Drawing
c) System.Control
d) System.IO
a) System.Windows.Forms
What is the purpose of an event handler?
a) To create graphical interfaces
b) To handle events triggered by user interactions
c) To generate SQL queries
d) To manage database connections
b) To handle events triggered by user interactions
What are the two parameters of an event handler in C#?
a) sender and EventArgs
b) source and EventHandler
c) Button and Label
d) Component and Control
a) sender and EventArgs
How can you add a button to a Form in Visual Studio?
a) By writing the code manually
b) By dragging it from the Toolbox
c) By importing it from a library
d) By creating a new namespace
b) By dragging it from the Toolbox
Which category of design patterns deals with object creation?
a) Behavioral patterns
b) Structural patterns
c) Creational patterns
d) Procedural patterns
c) Creational patterns
What does the Adapter pattern do?
a) Converts one interface to another
b) Manages object creation
c) Defines a template for methods
d) Updates relational databases
a) Converts one interface to another
The Bridge pattern helps to:
a) Link two separate applications
b) Decouple abstraction from implementation
c) Create database connections
d) Synchronize data between tables
b) Decouple abstraction from implementation
Which pattern notifies dependent objects of state changes?
a) Factory Method
b) Observer
c) Adapter
d) Singleton
b) Observer
The Factory Method pattern:
a) Creates an object without specifying the exact class
b) Updates existing objects
c) Directly accesses private attributes
d) Bridges two incompatible classes
a) Creates an object without specifying the exact class
What is an update anomaly?
a) When data is duplicated in a table
b) Inconsistent data after a partial update
c) Loss of data due to a deletion
d) Inability to add new data
b) Inconsistent data after a partial update
In which normal form must a table have no multi-valued columns?
a) 1NF
b) 2NF
c) 3NF
d) BCNF
a) 1NF
What is a transitive dependency?
a) When one column depends on another non-key column
b) When a column depends on the primary key
c) When a table has no foreign keys
d) When a table is in 1NF
a) When one column depends on another non-key column
What is the purpose of normalization?
a) To reduce data redundancy and improve integrity
b) To increase the size of databases
c) To create graphical interfaces
d) To manage database connections
a) To reduce data redundancy and improve integrity
Which type of anomaly occurs when you cannot add data to a table due to missing related data?
a) Update anomaly
b) Insert anomaly
c) Delete anomaly
d) Referential anomaly
b) Insert anomaly
Which SQL command is used to retrieve data?
a) SELECT
b) INSERT
c) UPDATE
d) DELETE
a) SELECT
What does the following SQL command do?
INSERT INTO Customers (Name, Country) VALUES (‘John’, ‘USA’);
a) Deletes a record from the Customers table
b) Updates a record in the Customers table
c) Adds a new record to the Customers table
d) Retrieves data from the Customers table
c) Adds a new record to the Customers table
Which SQL command modifies existing records?
a) SELECT
b) INSERT
c) UPDATE
d) DELETE
c) UPDATE
How do you remove a record in SQL?
a) SELECT * FROM table
b) DELETE FROM table
c) DROP table
d) REMOVE FROM table
b) DELETE FROM table
What is a stored procedure?
a) A predefined SQL query stored in the database
b) A temporary table in the database
c) A graphical component in SQL Server
d) A runtime error handler
a) A predefined SQL query stored in the database
What is the keyword void used for?
a) Declaring a class
b) Indicating no return value for a method
c) Creating variables
d) Handling exceptions
b) Indicating no return value for a method
What is an event-driven program?
a) A program where events trigger specific actions
b) A program that runs without input
c) A program that generates reports
d) A program that creates GUIs automatically
a) A program where events trigger specific actions
What is the difference between 2NF and 3NF?
a) 2NF eliminates multi-valued columns; 3NF eliminates transitive dependencies.
b) 2NF removes duplicates; 3NF removes foreign keys.
c) 2NF focuses on partial keys; 3NF focuses on normalization.
d) There is no difference.
a) 2NF eliminates multi-valued columns; 3NF eliminates transitive dependencies.
Which of the following is a creational pattern?
a) Observer
b) Adapter
c) Factory Method
d) Bridge
c) Factory Method
Which method executes when the application starts?
a) StaticMethod
b) Main
c) Execute
d) Start
b) Main
What is an abstraction in the Bridge pattern?
a) The interface seen by the client
b) The class implementing the interface
c) The database schema
d) The event handler
a) The interface seen by the client
Why use design patterns?
a) To make code more reusable and flexible
b) To avoid using classes
c) To prevent application execution
d) To remove attributes from methods
a) To make code more reusable and flexible
What does the Factory Method pattern enable?
a) Direct instantiation of objects
b) Subclasses to decide object creation
c) Singleton implementation
d) Access to private variables
b) Subclasses to decide object creation
Which design pattern is used when a client needs to work with a legacy system?
a) Singleton
b) Observer
c) Adapter
d) Bridge
c) Adapter
What is the role of the Adaptee in the Adapter pattern?
a) It converts the interface for the client.
b) It is the class being adapted.
c) It defines the new interface.
d) It handles event-driven programming.
b) It is the class being adapted.
The Observer pattern involves which of the following components?
a) Singleton, Adapter, Bridge
b) Subject, Observer, ConcreteObserver
c) Factory, Adapter, Observer
d) Client, Factory, Object
b) Subject, Observer, ConcreteObserver
In the Bridge pattern, what connects the abstraction to its implementation?
a) Event handler
b) Refined abstraction
c) Interface
d) Implementor
d) Implementor
Which design pattern is ideal for ensuring that only one instance of a class exists?
a) Adapter
b) Factory Method
c) Singleton
d) Bridge
c) Singleton
A behavioral design pattern primarily focuses on:
a) Object creation
b) Object structure
c) Object interactions
d) Object accessibility
c) Object interactions
What is the purpose of the Singleton pattern?
a) To manage complex inheritance hierarchies
b) To create multiple objects simultaneously
c) To ensure a class has only one instance
d) To notify observers of state changes
c) To ensure a class has only one instance
Which pattern is used to separate object creation from its usage?
a) Observer
b) Factory Method
c) Adapter
d) Bridge
b) Factory Method
What is an example of the Strategy pattern in real life?
a) Choosing different payment methods (e.g., credit card, PayPal) at checkout
b) Converting one currency to another
c) Ensuring only one user can log in at a time
d) Providing a graphical interface for a database
a) Choosing different payment methods (e.g., credit card, PayPal) at checkout
Which design pattern uses delegates to handle multiple events?
a) Observer
b) Factory Method
c) Adapter
d) Strategy
a) Observer
What kind of methods does an abstract class contain in the Template Method pattern?
a) Only private methods
b) Only concrete methods
c) Both abstract and concrete methods
d) Only static methods
c) Both abstract and concrete methods
The Adapter pattern works at which level?
a) Object level
b) Database level
c) Application level
d) Event level
a) Object level
Which pattern is commonly used in GUIs to decouple user input from internal logic?
a) Adapter
b) Observer
c) Factory Method
d) Singleton
b) Observer
What does a static method allow?
a) Methods to return values to other classes
b) The method to execute without creating an instance of the class
c) Access to private variables
d) Defining class-level variables
b) The method to execute without creating an instance of the class
What is the correct SQL syntax to update a customer’s name?
a) sql\nDELETE FROM Customers WHERE Name = ‘John’;
b) sql\nSELECT Name FROM Customers WHERE Name = ‘John’;
c) sql\nUPDATE Customers SET Name = ‘Jane’ WHERE Name = ‘John’;
d) sql\nINSERT INTO Customers (Name) VALUES (‘Jane’);
c) sql\nUPDATE Customers SET Name = ‘Jane’ WHERE Name = ‘John’;
Which SQL command creates a new table?
a) SELECT
b) CREATE TABLE
c) UPDATE
d) DROP TABLE
b) CREATE TABLE
What is the purpose of transitive dependency elimination in normalization?
a) To increase redundancy
b) To ensure no non-key column depends on another non-key column
c) To reduce table size
d) To ensure primary keys are unique
b) To ensure no non-key column depends on another non-key column