MCSD.NET - 70-340 Exam Question:
Download Questions PDF

Suppose You are an application developer for your company. You are conducting a code review of a
Windows Forms application that was developed by another developer. The application
includes a function named Logon(), which validates a users logon credentials. The function
displays a dialog box for the user to enter the users credentials, and the function validates those
credentials by using a database.
The function returns a value of 0 if the users password is incorrect, a value of 1 if the users user
ID is incorrect, and a value of 2 if both are correct. Users should receive access to the application
only if the function returns a value of 2. A function named EndApp() is used to exit the application.
The application must display a message to the user, depending on the result of the Logon()
function.
The application contains the following code segment.
int logonresult = Logon();
switch(logonresult) {
case 0:
MessageBox.Show("User name is OK, password incorrect.");
break;
case 1:
MessageBox.Show("User name is incorrect.");
break;
default:
MessageBox.Show("Welcome!");
break;
}
if(logonresult != 2) {
EndApp();
}
You need to improve the security of this code segment while maintaining its funtionality. You
decide to replace the existing code segment.
Which code segment should you use?
A. if(Logon() != 2) {
Console.WriteLine("Logon error.");
EndApp();
}
B. if(Logon() != 2) {
Console.WriteLine("Logon error.");
EndApp();
}
else {
MessageBox.Show("Welcome!");
}
C. int logonresult = Logon();
switch(logonresult) {
case 0:
MessageBox.Show("User name is OK, password incorrect.");
EndApp();
break;
case 1:
MessageBox.Show("User name is incorrect.");
EndApp();
break;
default:
MessageBox.Show("Welcome!");
break;
}
D. int logonresult = Logon();
if(logonresult == 2) {
MessageBox.Show("Welcome!");
}
else {
MessageBox.Show("User name or password was incorrect.");
EndApp();
}

Answer:

D. int logonresult = Logon();
if(logonresult == 2) {
MessageBox.Show("Welcome!");
}
else {
MessageBox.Show("User name or password was incorrect.");
EndApp();
}

Download MCSD.NET - 70-340 Exam Interview Questions And Answers PDF

Previous QuestionNext Question
Suppose You create a Web Forms application to track
employee expense report information. Information is entered by each user and stored in a
Microsoft SQL Server database. The application uses Integrated Windows authentication with
impersonation enabled to communicate with the database. All users are assigned to the
DataReader role and the DataWriter role in SQL Server.
The employee expense report form contains client-side validation scripts and additional server
controls. This form is ViewState enabled. All employee expense reports must be approved by the
accounting department by using a separate form in the application before payment is made.
You need to unit exam the security of the application.
What should you do?
A. Copy the ViewState information to a text file and attempt to decrypt it.
B. Exam the application from the hosting computer and from the client computers.
C. Create your own page that mimics the approved page and submit that page to the server.
D. Sign on as a user in the accounting department and verify that you can approve expense
reports.
How to prevent malicious code from running, a
written company policy does not permit developers to log on by using accounts that have more
permissions than necessary.
Your user account is a member of the Users group and the VS Developers group. You attempt to
run an application that requires Administrator-level permissions. You receive an error message
that states that permission is denied.
You need to be able to run the application.
What should you do?
A. Ask the network administrator to add your user account to the domain Administrators group.
B. Ask the administrator of your client computer to add your user account to the local
Administrators group.
C. Add the administrator of your client computer to add your user account to the Power Users
group.
D. Run the application by using the runas command and specify a user account in the local
Administrators group.