PrepAway - Latest Free Exam Questions & Answers

Author: seenagape

(Line numbers are included for reference only.) 01 publ…

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.)
01 public class TabDelimitedFormatter : IOutputFormatter<string>
02 {
03 readonly Func<int, char> suffix = col => col % 2 == 0 ? ‘\\n’ : ‘\\t’;
04 public string GetOutput(IEnumerator<string> iterator, int recordSize)
05 {
06
07 }
08 }
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 youinsert at line 06?

(Line numbers are included for reference only.) 01 publ…

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.)
01 public class TabDelimitedFormatter : IOutputFormatter<string>
02 {
03 readonly Func<int, char> suffix = col => col % 2 == 0 ? ‘\\n’ : ‘\\t’;
04 public string GetOutput(IEnumerator<string> iterator, int recordSize)
05 {
06
07 }
08 }
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 youinsert at line 06?

Which two code segments can you use to achieve this goal?

You are developing an application. The application includes classes named Employee and Person and an
interface named IPerson. The Employee class must meet the following requirements:
it must either inherit from the Person class or implement the IPerson interface.
it must be inheritable by other classes in the application.
You need to ensure that the Employee class meets the requirements. Which two code segments can you use
to achieve this goal? (Each correct answer presents a complete solution. Choose two.)

Which code segment should you use?

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?

Which code segment should you insert at line 07?

You are developing an application by using C#. The application includes the following code segment. (Line
numbers are included for reference only.)
01 public interface IDataContainer
02 {
03 string Data { get; set; }
04 }
05 void DoWork(object obj)
06 {
07
08 if (dataContainer != null)
09 {
10 Console.WriteLine(dataContainer.Data);
11 }
12 }
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?

Which code segment should you insert at line 20?

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.)
01 public enum Compass
02 {03 North,
04 South,
05 East,
06 West
07 }
08 [DataContract]
09 public class Location
10 {
11 [DataMember]
12 public string Label { get; set; }
13 [DataMember]
14 public Compass Direction { get; set; }
15 }
16 void DoWork()
17 {
18 var location = new Location { Label = “Test”, Direction = Compass.West};
19 Console.Writeline(WriteObject(location,
20
21 ));
22 }
You need to serialize the Location object as a JSON object. Which code segment should you insert at line
20?

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?


Page 714 of 6,830« First...102030...712713714715716...720730740...Last »