1.
You create 4 forms FormA, FormB, FormC and FormD. You want to allow users to open FormA, FormB and FormC at the same time within FormD. Which properties do you need to set?
Correct Answer
B. MdiParent on Forms A,B and C; and IsMdiContainer on FormD.
Explanation
You need to set the MdiParent on Forms A,B and C to the value �FormD�. There is no property named �IsMdiParent� � �IsMdiContainer� must be set to true on FormD.
2.
You create a custom control, which a user can drag and drop on his form. You want to create custom properties for your control, which the user can set using the Properties window of the Visual Studio IDE. What attribute can you use to control the visibility of the properties in the Properties window in the Visual Studio IDE?
Correct Answer
C. Browsable
Explanation
The Browsable attribute can be used to control the visibility of the properties in the Properties window of the Visual Studio IDE. By setting this attribute to true, the properties will be visible and editable in the Properties window, allowing the user to set them. Conversely, setting the attribute to false will hide the properties from the Properties window, preventing the user from modifying them.
3.
You create a SqlCommand object �com� in order to execute a SQL Query on a database table. Which code snippet should you use in order to select all records from the table �Customers�?
Correct Answer
D. Com.CommandText = �Customers�; com.CommandType = CommandType.TableDirect;
Explanation
The correct answer is com.CommandText = "Customers"; com.CommandType = CommandType.TableDirect; because the "Customers" table is being selected using the CommandType.TableDirect enumeration value. This value indicates that the command text is a table name rather than a SQL query or stored procedure.
4.
You have added a button named Bt1 to your form, whose Text is �Go�. You want to assign a shortcut to the button so that whenever a user presses ALT+G, the Click event of the button Bt1 is raised. What code should you use?
Correct Answer
B. Bt1.Text = �&Go�;
Explanation
Specifying the �&� character in front of any character in the Text property, causes the succeeding character to be displayed with an underline below it, and causes that character along with the ALT character to act as a shortcut.
5.
Which property of the web browser control should you use in order to navigate to a specified URL?
Correct Answer
C. Url
Explanation
The correct answer is "Url". The Url property of the web browser control is used to navigate to a specified URL. This property allows you to set the URL of the web page that you want to display in the control. By assigning a valid URL to the Url property, the web browser control will navigate to that URL and load the corresponding web page.
6.
You are creating a setup and deployment project for your application. You want to ensure that the .NET Framework 2.0 is installed on the computers of the users who want to install your application. Which deployment editor should you use?
Correct Answer
C. Launch Conditions Editor
Explanation
The conditions in the Launch Conditions Editor are checked before the application installation starts.
7.
You add a PictureBox control to your form, in order to display images to the user. Usually, you see that the images are smaller in size than the PictureBox control. What value of the SizeMode property should you set so that the size of the images adjust to fill the PictureBox control?
Correct Answer
B. StretchImage
Explanation
You should set PictureBox.SizeMode=StretchImage so that the image stretches to fill the PictureBox control.
8.
You use a TransactionScope in your application in your application in order to use transaction semantics. What code should you use in order to commit the transaction within the transaction scope?
Correct Answer
C. TransactionScope.Complete();
Explanation
To commit the transaction within the transaction scope, you should use the code TransactionScope.Complete(). This method marks the transaction as complete and allows it to be committed.
9.
You decide to use named parameters in a SqlCommand object in order to execute SQL queries on a database. You have a parameter named �CustomerName�. How do you refer to it within the SQL query text in the SqlCommand object?
Correct Answer
C. �@CustomerName�
Explanation
You should use code like:
SqlCommand.CommanText = �SELECT * FROM Customers WHERE CustomerName=@CustomerName�;
SqlCommand.Parameters.Add(�@CustomerName�, �customer name here�);
10.
Which function of the SqlCommand object must you use in order to execute an �INSERT� SQL Query?
Correct Answer
B. ExecuteNonQuery();
Explanation
You should use ExecuteNonQuery() to insert any SQL statement which does not return a dataset.
11.
You have a textbox control on your form. You want to store some custom data associated with that object. This data should not be visible to the user � it is meant for internal use in your application. What code should you use?
Correct Answer
B. Use the Tag property.
Explanation
You should use the Tag property to store custom data with a Control.
12.
You want to create a reusable control by combining existing Windows Controls in order to use it in various of your applications. What should the base class of your control be?
Correct Answer
A. System.Windows.Forms.UserControl
Explanation
The correct answer is System.Windows.Forms.UserControl because UserControl is a class in the System.Windows.Forms namespace that provides a base class for creating controls that can be used in multiple applications. It allows you to combine and customize existing Windows Controls to create a new control that can be easily reused in different applications.
13.
You have a textbox Text1 and an ErrorProvider ep1 on your form. You want to display an error message on your form when invalid data in Text1 is entered. What code should you use?
Correct Answer
C. Ep1.SetError(Text1, �invalid data�);
Explanation
The correct code to display an error message on the form when invalid data is entered in Text1 is "ep1.SetError(Text1, 'invalid data')". This code sets the error message "invalid data" for the control Text1 using the ErrorProvider ep1.
14.
You create a function F, which will be executed in a separate thread. You create a thread object T, and use a ParameterizedThreadStart delegate passing in F, so that when the thread starts, F will get executed. What should the signature of the function F be?
Correct Answer
C. Void return type, object parameter
Explanation
The function F should have a void return type because it is not required to return any value. It should have an object parameter because the ParameterizedThreadStart delegate expects a method with a single object parameter.
15.
You want to create an XmlDocument object in order to read XML data stored in a file �input.xml�. Which code should you use?
Correct Answer
B. XmlDocument doc = new XmlDocument(); doc.Load("input.xml");
Explanation
The correct code to create an XmlDocument object and read XML data stored in a file "input.xml" is "XmlDocument doc = new XmlDocument(); doc.Load("input.xml");". This code initializes an XmlDocument object and then uses the Load method to load the XML data from the file "input.xml" into the XmlDocument object.
16.
You want to access websites on the internet using HTTP. Which of the classes below can you use?
Correct Answer(s)
A. System.Net.WebClient
D. System.Net.HttpWebRequest
Explanation
You can use System.Net.WebClient and System.Net.HttpWebRequest to access websites on the internet using HTTP.
17.
You create a function named �ThreadedFunction� which you will execute in a new Thread. To this function, you will pass the name of a file, and in the function, you will read the contents of that file. What code should you use to start the thread?
Correct Answer
C. Thread T = new Thread(new ParameterizedThreadStart("ThreadedFunction")); T.Start(filename);
Explanation
The correct code to start the thread is "Thread T = new Thread(new ParameterizedThreadStart("ThreadedFunction")); T.Start(filename);" This is because the "ParameterizedThreadStart" delegate allows you to pass a parameter to the thread function, in this case, the filename. The "Start" method is then called on the thread object to start the execution of the thread.
18.
You have a DataSet object ds1, which contains two tables � �Orders� and �OrderDetails�. The OrderId column in Orders is set to a DataColumn object called to, and the same column in the OrderDetails table is set to a DataColumn object called DCOI. Since this is a foreign key relationship, you want to capture this relationship in the dataset. What code would you use to link these two tables in the DataSet ds1?
Correct Answer
B. DataRelation dr = new DataRelation("relationname", dco, dcoi); ds1.Relations.Add(dr);
Explanation
The syntax for creating a DataRelation is:
DataRelation dr= new DataRelation(�relation name�, parentColumn, childColumn);
The DataSet.Relations.Add() method only accepts a DataRelation parameter.
19.
You have a .xml file and the corresponding .xsd. Which class should you use to validate the XML against the corresponding schema file?
Correct Answer
C. XmlReader
Explanation
You should use the XmlReader class. You should not use XmlValidatingReader, because this class has been marked as obsolete in .NET 2.0.
20.
You dynamically create a TextBox control tb1 in code at runtime. You want to associate an event handler with tb1 that gets fired when the user clicks tb1. What operator will you use to associate the event handling function with the Click event of tb1?
Correct Answer
C. +=
Explanation
You should use code like:
tb1.Click += new System.EventHandler(functionname);
21.
You use a DataTable to load data from the Orders Table from a database. The Orders table contains two columns of � Quantity and UnitPrice. You want to add another column, which computes the total price using the formula: TotalPrice=Quantity*UnitPrice. What code will you use to add this third column to the DataTable?
Correct Answer
C. DataTable.Columns.Add("TotalPrice", typeof(Double), "Quantity * UnitPrice");
Explanation
The correct answer is dataTable.Columns.Add("TotalPrice", typeof(Double), "Quantity * UnitPrice"). This code adds a new column named "TotalPrice" to the DataTable with a data type of Double. The expression "Quantity * UnitPrice" is used as the formula to compute the values for the new column.
22.
You want to make your application accessible to physically challenged users. Consider Windows Narrator. When controls receive focus, the Narrator speaks out the information given to it. Which properties does the Narrator speak out for a windows control?
Correct Answer(s)
B. AccessibleName
D. AccessibleDescription
Explanation
The Narrator speaks out the AccessibleName and AccessibleDescription properties for a windows control. These properties provide information about the control to visually impaired users. The AccessibleName property represents the name or label of the control, while the AccessibleDescription property provides a more detailed description of the control's purpose or function. By providing accurate and descriptive information in these properties, developers can ensure that visually impaired users can navigate and interact with the application effectively.
23.
When the user moves the mouse cursor over a Button control, you want to change the background colour of the button. When the user moves the mouse away from the Button, you want to restore the original background color of the Button. What events do you need to use?
Correct Answer
D. MouseHover and MouseLeave
Explanation
The correct answer is MouseOver and MouseLeave. The MouseOver event is triggered when the user moves the mouse cursor over the Button control, allowing us to change the background color of the button. The MouseLeave event is triggered when the user moves the mouse away from the Button, allowing us to restore the original background color of the Button. MouseHover and MouseOut are not the correct events in this scenario.
24.
You have a DataTable in your application which you display to the user. The user is allowed to enter some data in a textbox and then press the Update button to update the data in the data table. You want to add code to an event of the DataTable so that when a Row is being updated, a message box is displayed to the user. Which event of the DataTable should you use?
Correct Answer
C. RowChanging
Explanation
There are no events named RowUpdating and RowUpdated. The RowChanged event is not the correct event to use here since it is fired after the data has been updated. The Question asks for the message to be displayed while a row is being updated.
25.
You execute a number of SQL Queries on an SQLConnection object �conn�, in the context of a SqlTransaction �trans�. In your code, you have logic that aborts the transaction in some cases. What code would you use to abort the transaction so that the changes don�t get committed to the database?
Correct Answer
C. Trans.Rollback();
Explanation
The correct answer is trans.Rollback(). This code is used to abort the transaction and rollback any changes made within the transaction, ensuring that the changes are not committed to the database.
26.
You have code that executes SQL statements on a database within the context of a SQLTransaction. You want to ensure that no user can perform any updates in the database until your transaction is complete. What IsolationLevel should you use?
Correct Answer
C. Serializable
Explanation
The �Serializable� IsolationLevel places a lock on the database, preventing any other updates from occurring in the database until the transaction completes.
27.
You have a DataTable dt1, which contains data about registered users. There is a column in the data table named �IsApproved� which is a Boolean Column which determines whether the user has been approved or not. You add a Checkbox cb1 to your form. You want cb1 to be ticked or not depending on the IsApproved value of the current row in the table. What code should you use?
Correct Answer
C. Cb1.DataBindings.Add(�Checked�, dt1, �IsApproved�);
Explanation
The signature of the method is:
control.DataBindings.Add(�control property�, datatable /dataset object, �column name in Datatable/Dataset�);
28.
You use an AutoResetEvent object for synchronizing access to common variables from different threads. Which method of the AutoResetEvent would you call in order to signal to other threads that the current thread has finished accessing the common variables?
Correct Answer
C. Set
Explanation
The Set method of the AutoResetEvent object is used to signal to other threads that the current thread has finished accessing the common variables. This method allows other threads that are waiting on the AutoResetEvent to proceed and access the common variables.
29.
Within your Setup and Deployment project, you want certain actions to occur only if the user is installing the application on windows xp. What condition would you check for?
Correct Answer
B. VersionNT = 501;
Explanation
VersionNT>=500 will be true for all versions greater than or equal to Windows 2000. VersionNTName is an invalid property.
30.
You use a BackgroundWorker object in order to execute some work in a background thread. Whenever the percentage of the work done changes, you want to be notified so that you can update a progress bar control. What event handler of the BackgroundWorker object would you use?
Correct Answer
C. ProgressChanged
Explanation
The ProgressChanged event handler of the BackgroundWorker object would be used in this scenario. This event is raised when the progress of the background operation changes. By subscribing to this event, you can be notified whenever the percentage of the work done changes, allowing you to update a progress bar control accordingly.
31.
Your application assemblies need to be installed into the Global Assembly Cache. What deployment strategy should you adopt?
Correct Answer
A. Create a Setup Application
Explanation
You should create a setup project in order to copy assemblies into the GAC.
32.
You want to execute a DELETE SQL query on a table in a database. You want to retrieve the number of rows that were deleted. What code should you use?
Correct Answer
B. SqlCommand cmd = new SqlCommand(); cmd.CommandText = "DELETE FROM MyTable"; int rowcount = cmd.ExecuteNonQuery();
Explanation
The correct answer is to use the code: SqlCommand cmd = new SqlCommand(); cmd.CommandText = "DELETE FROM MyTable"; int rowcount = cmd.ExecuteNonQuery().
The ExecuteNonQuery() method is used to execute a SQL query that does not return any data. It is commonly used for executing INSERT, UPDATE, and DELETE queries. In this case, the DELETE query will delete rows from the table specified in the command text, and the number of affected rows will be returned as an integer value, which can be stored in the variable "rowcount".
33.
What event of the BackgroundWorker object will you use in order to execute code that should run when the background thread completes?
Correct Answer
B. RunWorkerCompleted
Explanation
The correct event to use in order to execute code that should run when the background thread completes is the RunWorkerCompleted event. This event is raised when the background operation has completed, been canceled, or has raised an exception. It provides a way to handle the completion of the background operation and perform any necessary cleanup or post-processing tasks.
34.
You want your application to load the localized resources for the French language, but you want numbers and date/times to be displayed in the United States format. What code should you use?
Correct Answer
A. Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr");
Explanation
The CurrentCulture property determines the formatting to use while displaying numbers, dates, and time. The CurrentUICulture property determines which localized resources to load.
35.
If the user presses a certain key combination (which includes ALT) while your control had focus, you want to receive a notification so that you can execute custom code. In your custom code, you want to prevent other controls from receiving notification about the key combination that was pressed. What should you do?
Correct Answer
D. Override the OnKeyDown method.
Explanation
You should override the OnKeyDown method, and not call the base implementation. If you just handle the KeyDown event, then other controls will also receive notifications. The KeyPress event and the OnKeyPress method wont allow you to determine if the ALT key was pressed or not.
36.
You are creating a custom control, which has a single custom event. When the user double-clicks the control in the designer, you want the code for the event handler for the custom event to be autogenerated. What should you do?
Correct Answer
A. Apply the DefaultEvent attribute to the class that represents your control. Specify the name of the event.
Explanation
By applying the DefaultEvent attribute to the class that represents the control and specifying the name of the event, the code for the event handler for the custom event will be autogenerated when the user double-clicks the control in the designer. This attribute allows the event to be set as the default event for the control, making it easier for developers to handle the event without manually writing the event handler code.
37.
You have a background worker object bw1. How do you assign the work to it that should be executed in a background thread?
Correct Answer
C. Bg1.DoWork += delegate { functionname(); }; bg1.RunWorkerAsync();
Explanation
The correct answer is bg1.DoWork += delegate { functionname(); }; bg1.RunWorkerAsync();. This is the correct way to assign work to a background worker object. The "+=" operator is used to add a delegate to the DoWork event, which specifies the method that will be executed in the background thread. Then, the RunWorkerAsync() method is called to start the background operation.
38.
You place a progress bar control on your form. From your code, you call the PerformStep() method on the progress bar object. By how much will the progressbar�s value increase?
Correct Answer
B. By the amount specified in the Step property
Explanation
The progress bar's value will increase by the amount specified in the Step property.