70-483 Premium Bundle

70-483 Premium Bundle

Programming in C# Certification Exam

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

Microsoft 70-483 Free Practice Questions

Q1. - (Topic 2) 

You are developing an application. 

The application contains the following code segment (line numbers are included for reference only): 

When you run the code, you receive the following error message: "Cannot implicitly convert type 'object'' to 'int'. An explicit conversion exists (are you missing a cast?)." 

You need to ensure that the code can be compiled. 

Which code should you use to replace line 05? 

A. var2 = arrayl[0] is int; 

B. var2 = ((List<int>)arrayl) [0]; 

C. var2 = arrayl[0].Equals(typeof(int)); 

D. var2 = (int) arrayl [0]; 

Answer:

Q2. - (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. 

The following code implements the methods. (Line numbers are included for reference only.) 

You have the following requirements: 

. The Calculatelnterest() method must run for all build configurations. . The LogLine() method must run only for debug builds. 

You need to ensure that the methods run correctly. 

What are two possible ways to achieve this goal? (Each correct answer presents a complete solution. Choose two.) 

A. Insert the following code segment at line 01: 

#region DEBUG 

Insert the following code segment at line 10: 

#endregion 

B. Insert the following code segment at line 10: 

[Conditional(MDEBUG")] 

C. Insert the following code segment at line 05: 

#region DEBUG 

Insert the following code segment at line 07: 

#endregion 

D. Insert the following code segment at line 01: 

#if DE30G 

Insert the following code segment at line 10: 

#endif 

E. Insert the following code segment at line 01: 

[Conditional(MDEBUG")] 

F. Insert the following code segment at line 05: 

#if DEBUG 

Insert the following code segment at line 07: 

#endif 

G. Insert the following code segment at line 10: [Conditional("RELEASE")] 

Answer: B,F 

Explanation: 

#if DEBUG: The code in here won't even reach the IL on release. [Conditional("DEBUG")]: This code will reach the IL, however the calls to the method will not execute unless DEBUG is on. http://stackoverflow.com/questions/3788605/if-debug-vs-conditionaldebug 

Q3. - (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:

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. 

Q4. - (Topic 2) 

You have the following code. (Line numbers are included for reference only). 

You need to complete the WriteTextAsync method. The solution must ensure that the code is not blocked while the file is being written. 

Which code should you insert at line 12? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer:

Explanation: await sourceStream.WriteAsync(encodedText, 0, encodedText.Length); 

The following example has the statement await sourceStream.WriteAsync(encodedText, 0, 

encodedText.Length);, which is a contraction of the following two statements: 

Task theTask = sourceStream.WriteAsync(encodedText, 0, encodedText.Length); 

await theTask; 

Example: The following example writes text to a file. At each await statement, the method immediately exits. When the file I/O is complete, the method resumes at the statement that follows the await statement. Note that the async modifier is in the definition of methods that use the await statement. 

public async void ProcessWrite() 

string filePath = @"temp2.txt"; 

string text = "Hello World\r\n"; 

await WriteTextAsync(filePath, text); 

private async Task WriteTextAsync(string filePath, string text) 

byte[] encodedText = Encoding.Unicode.GetBytes(text); 

using (FileStream sourceStream = new FileStream(filePath, 

FileMode.Append, FileAccess.Write, FileShare.None, 

bufferSize: 4096, useAsync: true)) 

await sourceStream.WriteAsync(encodedText, 0, encodedText.Length); 

}; 

Reference: Using Async for File Access (C# and Visual Basic) 

https://msdn.microsoft.com/en-us/library/jj155757.aspx 

Q5. DRAG DROP - (Topic 1) 

You are developing an application by using C#. The application will process several objects per second. 

You need to create a performance counter to analyze the object processing. 

Which three actions should you perform in sequence? (To answer, move the appropriate actions from the list of actions to the answer area and arrange them in the correct order.) 

Answer:  

Q6. - (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:

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 

Q7. - (Topic 2) 

You are creating a class named Loan. 

The Loan class must meet the following requirements: . Include a member that represents the rate for a Loan instance. . Allow external code to assign a value to the rate member. 

Restrict the range of values that can be assigned to the rate member. 

You need to implement the rate member to meet the requirements. 

In which form should you implement the rate member? 

A. public static property 

B. public property 

C. public static field 

D. protected field 

Answer:

Q8. - (Topic 1) 

You are developing an application by using C#. You provide a public key to the 

development team during development. 

You need to specify that the assembly is not fully signed when it is built. 

Which two assembly attributes should you include in the source code? (Each correct 

answer presents part of the solution. Choose two.) 

A. AssemblyFlagsAttribute 

B. AssemblyKeyFileAttribute 

C. AssemblyConfigurationAttribute 

D. AssemblyDelaySignAttribute 

Answer: B,D 

Q9. - (Topic 1) 

You are developing an application by using C#. 

The application includes an object that performs a long running process. 

You need to ensure that the garbage collector does not release the object's resources until the process completes. 

Which garbage collector method should you use? 

A. WaitForFullGCComplete() 

B. SuppressFinalize() 

C. collect() 

D. RemoveMemoryPressure() 

Answer:

Q10. - (Topic 1) 

You are developing an application by using C#. 

The application includes an object that performs a long running process. 

You need to ensure that the garbage collector does not release the object's resources until 

the process completes. 

Which garbage collector method should you use? 

A. ReRegisterForFinalize() 

B. SuppressFinalize() 

C. Collect() 

D. WaitForFullGCApproach() 

Answer:

Q11. - (Topic 2) 

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

public void ProcessReports(List<decimal> values,CancellationTokenSource cts, CancellationToken ct) 

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 ProcessReports() method performs the required actions. 

Which code segment should you use in the method body? 

A. if (ct.IsCancellationRequested) return; 

B. ct.ThrowIfCancellationRequested() ; 

C. cts.Cancel(); 

D. throw new AggregateException(); 

Answer:

Q12. DRAG DROP - (Topic 2) 

You have an application that uses paging. Each page displays 10 items from a list. 

You need to display the third page. (Develop the solution by selecting and ordering the required code snippets. You may not need all of the code snippets.) 

Answer:  

Q13. - (Topic 2) 

You have the following code. (Line numbers are included for reference only.) 

When you execute the code, you get an exception. 

You need to ensure that B_Products contain all of the products that start with the letter “B”. What should you do? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer:

Explanation: Simply select the product items. 

Q14. - (Topic 2) 

You are developing an application that uses multiple asynchronous tasks to optimize performance. 

You need to retrieve the result of an asynchronous task. 

Which code segment should you use? 

A. Option A B. Option B 

C. Option C 

D. Option D 

Answer:

Q15. - (Topic 1) 

You are developing an application that uses the Microsoft ADO.NET Entity Framework to retrieve order information from a Microsoft SQL Server database. The application includes the following code. (Line numbers are included for reference only.) 

The application must meet the following requirements: 

. Return only orders that have an OrderDate value other than null. 

. Return only orders that were placed in the year specified in the OrderDate property or in a later year. 

You need to ensure that the application meets the requirements. 

Which code segment should you insert at line 08? 

A. Where order.OrderDate.Value != null && order.OrderDate.Value.Year > = year 

B. Where order.OrderDate.Value = = null && order.OrderDate.Value.Year = = year 

C. Where order.OrderDate.HasValue && order.OrderDate.Value.Year = = year 

D. Where order.OrderDate.Value.Year = = year 

Answer:

Explanation: *For the requirement to use an OrderDate value other than null use: OrderDate.Value != null 

*For the requirement to use an OrderDate value for this year or a later year use: OrderDate.Value>= year 

START 70-483 EXAM