70-483 Premium Bundle

70-483 Premium Bundle

Programming in C# Certification Exam

4.5 
(26205 ratings)
0 QuestionsPractice Tests
0 PDFPrint version
November 21, 2024Last update

Microsoft 70-483 Free Practice Questions

Q1. - (Topic 1) 

You are developing an application by using C#. The application includes the following code segment. (Line numbers are included for reference only.) 

The DoWork() method must not throw any exceptions when converting the obj object to the IDataContainer interface or when accessing the Data property. 

You need to meet the requirements. Which code segment should you insert at line 07? 

A. var dataContainer = (IDataContainer)obj; 

B. dynamic dataContainer = obj; 

C. var dataContainer = obj is IDataContainer; 

D. var dataContainer = obj as IDataContainer; 

Answer:

Explanation: 

As - The as operator is like a cast operation. However, if the conversion isn't possible, as returns null instead of raising an exception. http://msdn.microsoft.com/en-us/library/cscsdfbt(v=vs.110).aspx 

Q2. - (Topic 1) 

An application receives JSON data in the following format: 

The application includes the following code segment. (Line numbers are included for reference only.) 

You need to ensure that the ConvertToName() method returns the JSON input string as a Name object. 

Which code segment should you insert at line 10? 

A. Return ser.ConvertToType<Name>(json); 

B. Return ser.DeserializeObject(json); 

C. Return ser.Deserialize<Name>(json); 

D. Return (Name)ser.Serialize(json); 

Answer:

Explanation: 

JavaScriptSerializer.Deserialize<T> - Converts the specified JSON string to an object of type T. http://msdn.microsoft.com/en-us/library/bb355316.aspx 

Q3. - (Topic 2) 

You are implementing a method named ProcessData that performs a long-running task. The ProcessData() method has the following method signature: 

public void ProcessData(List<decimal> values, CancellationTokenSource source, CancellationToken token) 

If the calling code requests cancellation, the method must perform the following actions: 

. Cancel the long-running task. 

. Set the task status to TaskStatus.Canceled. You need to ensure that the ProcessData() method performs the required actions. 

Which code segment should you use in the method body? 

A. if (token.IsCancellationRequested) return; 

B. throw new AggregateException(); 

C. token.ThrowIfCancellationRequested(); 

D. source.Cancel(); 

Answer:

Q4. - (Topic 1) 

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

The GetAnimals() method must meet the following requirements: 

Connect to a Microsoft SQL Server database. 

Create Animal objects and populate them with data from the database. 

Return a sequence of populated Animal 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 16: while(sqlDataReader.NextResult()) 

B. Insert the following code segment at line 13: sqlConnection.Open(); 

C. Insert the following code segment at line 13: sqlConnection.BeginTransaction(); 

D. Insert the following code segment at line 16: while(sqlDataReader.Read()) 

E. Insert the following code segment at line 16: while(sqlDataReader.GetValues()) 

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 

Q5. - (Topic 2) 

You are developing an application that will read data from a text file and display the file contents. 

You need to read data from the file, display it, and correctly release the file resources. 

Which code segment should you use? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer:

Q6. - (Topic 1) 

You are developing an application that will convert data into multiple output formats. 

The application includes the following code. (Line numbers are included for reference only.) 

You are developing a code segment that will produce tab-delimited output. All output routines implement the following interface: 

You need to minimize the completion time of the GetOutput() method. Which code segment should you insert at line 06? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer:

Explanation: 

A String object concatenation operation always creates a new object from the existing string and the new data. A StringBuilder object maintains a buffer to accommodate the concatenation of new data. New data is appended to the buffer if room is available; otherwise, a new, larger buffer is allocated, data from the original buffer is copied to the new buffer, and the new data is then appended to the new buffer. The performance of a concatenation operation for a String or StringBuilder object depends on the frequency of memory allocations. A String concatenation operation always allocates memory, whereas a StringBuilder concatenation operation allocates memory only if the StringBuilder object buffer is too small to accommodate the new data. Use the String class if you are concatenating a fixed number of String objects. In that case, the compiler may even combine individual concatenation operations into a single operation. Use a StringBuilder object if you are concatenating an arbitrary number of strings; for example, if you're using a loop to concatenate a random number of strings of user input. 

http://msdn.microsoft.com/en-us/library/system.text.stringbuilder(v=vs.110).aspx 

START 70-483 EXAM