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 04?

You are implementing a method named Calculate that performs conversions between value types and
reference types. The following code segment implements the method. (Line numbers are included for reference
only.)
01 public static void Calculate(float amount)
02 {
03 object amountRef = amount;
04
05 Console.WriteLine(balance);
06 }You need to ensure that the application does not throw exceptions on invalid conversions. Which code segment
should you insert at line 04?

Which two actions should you perform?

You are creating a class named Employee. The class exposes a string property named EmployeeType. The
following code segment defines the Employee class. (Line numbers are included for reference only.)
01 public class Employee
02 {
03 internal string EmployeeType
04 {
05 get;
06 set;
07 }
08 }
The EmployeeType property value must be accessed only by code within the Employee class or within a
class derived from the Employee class. The EmployeeType property value must be modified only by code
within the Employee class. You need to ensure that the implementation of the EmployeeType property meets
the requirements. Which two actions should you perform? (Each correct answer represents part of the
complete solution. Choose two.)

(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?


Page 11 of 12« First...89101112