70-483 Premium Bundle

70-483 Premium Bundle

Programming in C# Certification Exam

4.5 
(780 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 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. WaitForFullGCApproach() 

C. KeepAlive() 

D. WaitForPendingFinalizers() 

Answer:

Explanation: The GC.KeepAlive method references the specified object, which makes it ineligible for garbage collection from the start of the current routine to the point where this method is called. The purpose of the KeepAlive method is to ensure the existence of a reference to an object that is at risk of being prematurely reclaimed by the garbage collector. The KeepAlive method performs no operation and produces no side effects other than extending the lifetime of the object passed in as a parameter. 

Q2. DRAG DROP - (Topic 2) 

You are creating a method that saves information to a database. 

You have a static class named LogHelper. LogHelper has a method named Log to log the exception. 

You need to use the LogHelper Log method to log the exception raised by the database server. The solution must ensure that the exception can be caught by the calling method, while preserving the original stack trace. 

How should you write the catch block? (Develop the solution by selecting and ordering the required code snippets. You may not need all of the code snippets.) 

Answer:  

Q3. DRAG DROP - (Topic 2) 

You are developing an application that will write string values to a file. The application includes the following code segment. (Line numbers are included for reference only.) 

01 protected void ProcessFile(string fileName, string value) 02 { 

04 } 

You need to ensure that the ProcessFile() method will write string values to a file. 

Which four code segments should you insert in sequence at line 03? (To answer, move the appropriate code segments from the list of code segments to the answer area and arrange them in the correct order.) 

Answer:  

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

Q5. - (Topic 1) 

You are developing an application. The application converts a Location object to a string by using a method named WriteObject. The WriteObject() method accepts two parameters, a Location object and an XmlObjectSerializer object. 

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

You need to serialize the Location object as a JSON object. 

Which code segment should you insert at line 20? 

A. New DataContractSerializer(typeof(Location)) 

B. New XmlSerializer(typeof(Location)) 

C. New NetDataContractSenalizer() 

D. New DataContractJsonSerializer(typeof(Location)) 

Answer:

Explanation: 

The DataContractJsonSerializer class serializes objects to the JavaScript Object Notation 

(JSON) and deserializes JSON data to objects. 

Use the DataContractJsonSerializer class to serialize instances of a type into a JSON 

document and to deserialize a JSON document into an instance of a type. 

Q6. DRAG DROP - (Topic 1) 

You are developing a class named ExtensionMethods. 

You need to ensure that the ExtensionMethods class implements the IsEmail() extension method on string objects. 

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:  

Q7. - (Topic 2) 

You have the following code (line numbers are included for reference only): 

You need to ensure that if an exception occurs, the exception will be logged. Which code should you insert at line 28? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer:

Explanation: * XmlWriterTraceListener 

Directs tracing or debugging output as XML-encoded data to a TextWriter or to a Stream, 

such as a FileStream. 

* TraceListener.TraceEvent Method (TraceEventCache, String, TraceEventType, Int32) Writes trace and event information to the listener specific output. 

Syntax: 

[ComVisibleAttribute(false)] 

public virtual void TraceEvent( 

TraceEventCache eventCache, 

string source, 

TraceEventType eventType, 

int id 

Q8. - (Topic 2) 

You need to create a method that can be called by using a varying number of parameters. 

What should you use? 

A. derived classes 

B. interface 

C. enumeration 

D. method overloading 

Answer:

Explanation: Member overloading means creating two or more members on the same type that differ only in the number or type of parameters but have the same name. Overloading is one of the most important techniques for improving usability, productivity, and readability of reusable libraries. Overloading on the number of parameters makes it possible to provide simpler versions of constructors and methods. Overloading on the parameter type makes it possible to use the same member name for members performing identical operations on a selected set of different types. 

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

Q10. - (Topic 2) 

You have the following code: 

You need to retrieve all of the numbers from the items variable that are greater than 80. Which code should you use? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer:

Explanation: Example: All number larger than 15 from a list using the var query = from num in numbers... contstruct: 

var largeNumbersQuery = numbers2.Where(c => c > 15); 

Reference: How to: Write LINQ Queries in C# 

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

Q11. - (Topic 1) 

You use the Task.Run() method to launch a long-running data processing operation. The data processing operation often fails in times of heavy network congestion. 

If the data processing operation fails, a second operation must clean up any results of the first operation. 

You need to ensure that the second operation is invoked only if the data processing operation throws an unhandled exception. 

What should you do? 

A. Create a task within the operation, and set the Task.StartOnError property to true. 

B. Create a TaskFactory object and call the ContinueWhenAll() method of the object. 

C. Create a task by calling the Task.ContinueWith() method. 

D. Use the TaskScheduler class to create a task and call the TryExecuteTask() method on the class. 

Answer:

Explanation: 

Task.ContinueWith - Creates a continuation that executes asynchronously when the target Task completes.The returned Task will not be scheduled for execution until the current task has completed, whether it completes due to running to completion successfully, faulting due to an unhandled exception, or exiting out early due to being canceled. http://msdn.microsoft.com/en-us/library/dd270696.aspx 

Q12. - (Topic 2) 

You are developing an application that uses multiple asynchronous tasks to optimize performance. The application will be deployed in a distributed environment. 

You need to retrieve the result of an asynchronous task that retrieves data from a web service. 

The data will later be parsed by a separate task. Which code segment should you use? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer:

Q13. - (Topic 1) 

You are adding a public method named UpdateScore to a public class named ScoreCard. 

The code region that updates the score field must meet the following requirements: . It must be accessed by only one thread at a time. . It must not be vulnerable to a deadlock situation. You need to implement the UpdateScore() method. 

What should you do? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer:

Explanation: 

http://blogs.msdn.com/b/bclteam/archive/2004/01/20/60719.aspx 

Q14. - (Topic 2) 

An application contains code that measures reaction times. The code runs the timer on a thread separate from the user interface. The application includes the following code. (Line numbers are included for reference only.) 

You need to ensure that the application cancels the timer when the user presses the Enter key. 

Which code segment should you insert at line 14? 

A. tokenSource.Token.Register( () => tokenSource.Cancel() ); 

B. tokenSource.Cancel(); 

C. tokenSource.IsCancellationRequested = true; 

D. tokenSource.Dispose(); 

Answer:

Q15. DRAG DROP - (Topic 2) 

You have an application that accesses a Microsoft SQL Server database. 

The database contains a stored procedure named Proc1. Proc1 accesses several rows of data across multiple tables. 

You need to ensure that after Proc1 executes, the database is left in a consistent state. While Proc1 executes, no other operation can modify data already read or changed by Proc1. (Develop the solution by selecting and ordering the required code snippets. 

You may not need all of the code snippets.) 

Answer:  

START 70-483 EXAM