Microsoft 70-483

Programming in C#

(Page 1 out of 16)
Showing 15 of 236 Questions
Exam Version: 9.0
Question No : 1 - Topic 1

You are developing code for a class named Account. The Account class includes the
following method:


You need to ensure that overflow exceptions are thrown when there is an error.
Which type of block should you use?

  • A. checked
  • B. try
  • C. using
  • D. unchecked

Answer : A



Question No : 2 - Topic 1

You are developing an application in C#.
The application will display the temperature and the time at which the temperature was
recorded. You have the following method (line numbers are included for reference only):


You need to ensure that the message displayed in the lblMessage object shows the time
formatted according to the following requirements:
✑ The time must be formatted as hour:minute AM/PM, for example 2:00 PM.
✑ The date must be formatted as month/day/year, for example 04/21/2013.
✑ The temperature must be formatted to have two decimal places, for example 23-
45.
Which code should you insert at line 04? (To answer, select the appropriate options in the
answer area.)

Answer :



Question No : 3 - Topic 1

You are developing an application that includes a class named Order. The application will
store a collection of Order objects.
The collection must meet the following requirements:
✑ Use strongly typed members.
✑ Process Order objects in first-in-first-out order.
✑ Store values for each Order object.
✑ Use zero-based indices.
You need to use a collection type that meets the requirements.
Which collection type should you use?

  • A. Queue<T>
  • B. SortedList
  • C. LinkedList<T>
  • D. HashTable
  • E. Array<T>

Answer : A

Explanation: Queues are useful for storing messages in the order they were received for sequential processing. Objects stored in a Queue<T> are inserted at one end and removed from the other. http://msdn.microsoft.com/en-us/library/7977ey2c.aspx



Question No : 4 - Topic 1

You are developing an application that includes the following code segment. (Line numbers
are included for reference only.)


The GetCustomers() method must meet the following requirements:
✑ Connect to a Microsoft SQL Server database.
✑ Populate Customer objects with data from the database.
✑ Return an IEnumerable<Customer> collection that contains the populated
Customer objects.
You need to meet the requirements.
Which two actions should you perform? (Each correct answer presents part of the solution.
Choose two.)

  • A. Insert the following code segment at line 17: while (sqlDataReader.GetValues())
  • B. Insert the following code segment at line 14: sqlConnection.Open();
  • C. Insert the following code segment at line 14: sqlConnection.BeginTransaction();
  • D. Insert the following code segment at line 17: while (sqlDataReader.Read())
  • E. Insert the following code segment at line 17: while (sqlDataReader.NextResult())

Answer : B,D

Explanation: SqlConnection.Open - Opens a database connection with the property settings specified by the ConnectionString. http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.open.aspx SqlDataReader.Read - Advances the SqlDataReader to the next record. http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.read.aspx



Question No : 5 - Topic 1

You are developing an application that will process orders. The debug and release versions
of the application will display different logo images.
You need to ensure that the correct image path is set based on the build configuration.
Which code segment should you use?


  • A. Option A
  • B. Option B
  • C. Option C
  • D. Option D

Answer : C

Explanation: There is no such constraint (unless you define one explicitly) RELEASE. http://stackoverflow.com/questions/507704/will-if-release-work-like-if-debug-does-in-c



Question No : 6 - Topic 1

You are creating an application that manages information about zoo animals. The
application includes a class named Animal and a method named Save.
The Save() method must be strongly typed. It must allow only types inherited from the
Animal class that uses a constructor that accepts no parameters.
You need to implement the Save() method.
Which code segment should you use?


  • A. Option A
  • B. Option B
  • C. Option C
  • D. Option D

Answer : C

Explanation: When you define a generic class, you can apply restrictions to the kinds of types that client code can use for type arguments when it instantiates your class. If client code tries to instantiate your class by using a type that is not allowed by a constraint, the result is a compile-time error. These restrictions are called constraints. Constraints are specified by using the where contextual keyword. http://msdn.microsoft.com/en-us/library/d5x73970.aspx



Question No : 7 - Topic 1

You are debugging an application that calculates loan interest. The application includes the
following code. (Line numbers are included for reference only.)


You have the following requirements:
✑ The debugger must break execution within the Calculatelnterest() method when
the loanAmount variable is less than or equal to zero.
✑ The release version of the code must not be impacted by any changes.
You need to meet the requirements.
What should you do?

  • A. Insert the following code segment at tine 05: Debug.Write(loanAmount > 0);
  • B. Insert the following code segment at line 05: Trace.Write(loanAmount > 0);
  • C. Insert the following code segment at line 03: Debug.Assert(loanAmount > 0);
  • D. Insert the following code segment at line 03: Trace.Assert(loanAmount > 0);

Answer : C

Explanation: By default, the Debug.Assert method works only in debug builds. Use the Trace.Assert method if you want to do assertions in release builds. For more information, see Assertions in Managed Code. http://msdn.microsoft.com/en-us/library/kssw4w7z.aspx



Question No : 8 - Topic 1

You are developing an application that includes a class named Customer.
The application will output the Customer class as a structured XML document by using the
following code segment:


You need to ensure that the Customer class will serialize to XML.
How should you complete the relevant code? (To answer, drag the appropriate code
segments to the correct locations in the answer area. Each code segment may be used
once, more than once, or not at all. You may need to drag the split bar between panes or
scroll to view content.)

Answer :



Question No : 9 - Topic 1

You are developing an application that includes a class named Order. The application will
store a collection of Order objects.
The collection must meet the following requirements:
✑ Internally store a key and a value for each collection item.
✑ Provide objects to iterators in ascending order based on the key.
✑ Ensure that item are accessible by zero-based index or by key.
You need to use a collection type that meets the requirements.
Which collection type should you use?

  • A. LinkedList
  • B. Queue
  • C. Array
  • D. HashTable
  • E. SortedList

Answer : E

Explanation: SortedList<TKey, TValue> - Represents a collection of key/value pairs that are sorted by key based on the associated IComparer<T> implementation. http://msdn.microsoft.com/en-us/library/ms132319.aspx



Question No : 10 - Topic 1

You are developing an application that uses structured exception handling. The application
includes a class named ExceptionLogger.
The ExceptionLogger class implements a method named LogException by using the
following code segment:
public static void LogException(Exception ex)
You have the following requirements:
✑ Log all exceptions by using the LogException() method of the ExceptionLogger
class.
✑ Rethrow the original exception, including the entire exception stack.
You need to meet the requirements.
Which code segment should you use?


  • A. Option A
  • B. Option B
  • C. Option C
  • D. Option D

Answer : A

Explanation: Once an exception is thrown, part of the information it carries is the stack trace. The stack trace is a list of the method call hierarchy that starts with the method that throws the exception and ends with the method that catches the exception. If an exception is re- thrown by specifying the exception in the throw statement, the stack trace is restarted at the current method and the list of method calls between the original method that threw the exception and the current method is lost. To keep the original stack trace information with the exception, use the throw statement without specifying the exception. http://msdn.microsoft.com/en-us/library/ms182363(v=vs.110).aspx



Question No : 11 - Topic 1

You are testing an application. The application includes methods named CalculateInterest
and LogLine. The CalculateInterest() method calculates loan interest. The LogLine()
method sends diagnostic messages to a console window.
You have the following requirements:
✑ The CalculateInterest() method must run for all build configurations.
✑ The LogLine() method must be called only for debug builds.
You need to ensure that the methods run correctly.
How should you complete the relevant code? (To answer, drag the appropriate code
segments to the correct locations in the answer area. Each code segment may be used
once, more than once, or not at all. You may need to drag the split bar between panes or
scroll to view content.)


Answer :



Question No : 12 - Topic 1

You are developing an application that accepts the input of dates from the user.
Users enter the date in their local format. The date entered by the user is stored in a string
variable named inputDate. The valid date value must be placed in a DateTime variable
named validatedDate.
You need to validate the entered date and convert it to Coordinated Universal Time (UTC).
The code must not cause an exception to be thrown.
Which code segment should you use?


  • A. Option A
  • B. Option B
  • C. Option C
  • D. Option D

Answer : A

Explanation: AdjustToUniversal parses s and, if necessary, converts it to UTC. Note: The DateTime.TryParse method converts the specified string representation of a date and time to its DateTime equivalent using the specified culture-specific format information and formatting style, and returns a value that indicates whether the conversion succeeded.



Question No : 13 - Topic 1

You are developing an application that uses a .config file.
The relevant portion of the .config file is shown as follows:


You need to ensure that diagnostic data for the application writes to the event tog by using
the configuration specified in the .config file.
What should you include in the application code?

  • A. Option A
  • B. Option B
  • C. Option C
  • D. Option D

Answer : D



Question No : 14 - Topic 1

An application includes a class named Person. The Person class includes a method named
GetData.
You need to ensure that the GetData() from the Person class.
Which access modifier should you use for the GetData() method?

  • A. Internal
  • B. Protected
  • C. Private
  • D. Protected internal
  • E. Public

Answer : B

Explanation: Protected - The type or member can be accessed only by code in the same class or structure, or in a class that is derived from that class. http://msdn.microsoft.com/en-us/library/ms173121.aspx The protected keyword is a member access modifier. A protected member is accessible within its class and by derived class instances.



Question No : 15 - Topic 1

You are developing an application that will include a method named GetData. The
GetData() method will retrieve several lines of data from a web service by using a
System.IO.StreamReader object.
You have the following requirements:
✑ The GetData() method must return a string value that contains the entire response
from the web service.
✑ The application must remain responsive while the GetData() method runs.
You need to implement the GetData() method.
How should you complete the relevant code? (To answer, drag the appropriate objects to
the correct locations in the answer area. Each object may be used once, more than once,
or not at all. You may need to drag the split bar between panes or scroll to view content.)


Answer :



(Page 1 out of 16)
Showing of 236 Questions
Exam Version: 9.0