PrepAway - Latest Free Exam Questions & Answers

Category: 70-483 (v.5)

Exam 70-483: Programming in C# (update May 25th, 2017)

Which code segment should you insert at line 10?

An application receives JSON data in the following format:
{ “FirstName” : “David”,
“LastName” : “Jones”,
“Values” : [0, 1, 2] }
The application includes the following code segment. (Line numbers are included for reference only.)
01 public class Name
02 {
03 public int[] Values { get; set; }
04 public string FirstName { get; set; }
05 public string LastName { get; set; }
06 }
07 public static Name ConvertToName(string json)
08 {
09 var ser = new JavaScriptSerializer();
10
11 }
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?

Which code segment should you use?

You are developing an application. The application includes a method named ReadFile that reads data from a
file. The ReadFile() method must meet the following requirements:
It must not make changes to the data file.
It must allow other processes to access the data file.
It must not throw an exception if the application attempts to open a data file that does not exist.
You need to implement the ReadFile method. Which code segment should you use?

(Line numbersare included for reference only.) 01 publi…

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 numbersare included for reference only.)
01 public DateTime? OrderDate;
02 IQueryable<Order> LookupOrdersForYear(int year)
03 {
04 using (var context = new NorthwindEntities())
05 {
06 var orders =
07 from order in context.Orders
08
09 select order;
10 return orders.ToList().AsQueryable();
11 }
12 }
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 by the method year parameter
not raise an exception
You need to ensure that the application meets the requirements. Which code segment should you insert at line
08?

Which two actions should you perform?

You are developing an application that includes the following code segment. (Line numbers are included forreference only.)
01 class Animal
02 {
03 public string Color { get; set; }
04 public string Name { get; set; }
05 }
06 private static IEnumerable<Animal> GetAnimals(string sqlConnectionString)
07 {
08 var animals = new List<Animal>();
09 SqlConnection sqlConnection = new SqlConnection(sqlConnectionString);
10 using (sqlConnection)
11 {
12 SqlCommand sqlCommand = new SqlCommand(“SELECT Name, ColorName FROM
Animals”, sqlConnection);
13
14 using (SqlDataReader sqlDataReader = sqlCommand.ExecuteReader())
15 {
16
17 {
18 var animal = new Animal();
19 animal.Name = (string)sqlDataReader[“Name”];
20 animal.Color = (string)sqlDataReader[“ColorName”];
21 animals.Add(animal);
22 }
23 }
24 }
25 return animals;
26 }
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.)

Which code segment should you use?

You are developing an application. The application calls a method that returns an array of integers named
employeeIds. You define an integer variable named employeeIdToRemove and assign a value to it. You
declare an array named filteredEmployeeIds. You have the following requirements:
Remove duplicate integers from the employeeIds array.
Sort the array in order from the highest value to the lowest value.
Remove the integer value stored in the employeeIdToRemove variable from the employeeIds array.
You need to create a LINQ query to meet the requirements. Which code segment should you use?


Page 12 of 12« First...89101112