PrepAway - Latest Free Exam Questions & Answers

Tag: Exam 70-483 (update May 25th, 2017)

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

What are two possible ways to achieve this goal?

You are testing an application. The application includes methods named Calculatelnterest and LogLine.
The Calculatelnterest() 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.)
01
02 private static decimal CalculateInterest(decimal loanAmount, int loanTerm,
decimal loanRate)
03 {
04 decimal interestAmount = loanAmount * loanRate * loanTerm;
05
06 LogLine(“Interest Amount : “, interestAmount.ToString(“c”));
07
08 return interestAmount;
09 }
10
11 public static void LogLine(string message, string detail)
12 {
13 Console.WriteLine(“Log: {0} = {1}”, message, detail);
14 }
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.)

You need to meet the requirements

You are debugging an application that calculates loan interest. The application includes the following code.
(Line numbers are included for reference only.)
01 private static decimal CalculateInterest(decimal loanAmount, int loanTerm,
decimal loanRate)
02 {
03
04 decimal interestAmount = loanAmount * loanRate * loanTerm;
05
06 return interestAmount;
07 }
You have the following requirements:
he debugger must break execution within the Calculatelnterest() method when the loanAmount
variable is less than or equal to zero.
the release version of the code must not be impacted by any changes.
You need to meet the requirements. What should you do?

Which code segment should you add at line 19?

You are developing an application that includes the following code segment. (Line numbers are included for
reference only.)
01 using System;
02 class MainClass
03 {
04 public static void Main(string[] args)
05 {
06 bool bValidInteger = false;
07 int value = 0;
08 do
09 {
10 Console.WriteLine(“Enter an integer”);
11 bValidInteger = GetValidInteger(ref value);
12 } while (!bValidInteger);
13 Console.WriteLine(“You entered a valid integer, ” + value);
14 }
15 public static bool GetValidInteger(ref int val)
16 {
17 string sLine = Console.ReadLine();
18 int number;
19
20 {
21 return false;
22 }
23 else
24 {
25 val = number;
26 return true;
27 }
28 }
29 }
You need to ensure that the application accepts only integer input and prompts the user each time non-integer
input is entered. Which code segment should you add at line 19?

Which collection type should you use?

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?

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 XML. Which code segment should you insert at line 20?

Which code segment should you insert at line 04?

An application will upload data by using HTML form-based encoding. The application uses a method named
SendMessage. The SendMessage() method includes the following code. (Line numbers are included for
reference only.)
01 public Task<byte[]> SendMessage(string url, int intA, int intB)
02 {
03 var client = new WebClient();
04
05 }
The receiving URL accepts parameters as form-encoded values. You need to send the values intA and intB
as form-encoded values named a and b, respectively. Which code segment should you insert at line 04?

Which two actions should you perform?

You are developing an application that includes the following code segment. (Line numbers are included for
reference only.)
01 class Customer
02 {
03 public string CompanyName { get; set; }
04 public string Id { get; set; }
05 }
06 const string sqlSelectCustomerss = “SELECT CustomerID, CompanyName FROM
Customers”;
07 private static IEnumerable<Customer> GetCustomers(string sqlConnectionString)
08 {
09 List<Customer> customers = new List<Customer>();
10 SqlConnection sqlConnection = new SqlConnection(sqlConnectionString);
11 using (sqlConnection)
12 {
13 SqlCommand sqlCommand = new SqlCommand(sqlSelectCustomers,
sqlConnection);
14
15 using (SqlDataReader sqlDataReader = sqlCommand.ExecuteReader())
16 {17
18 {
19 Customer customer = new Customer();
20 customer.Id = (string)sqlDataReader[“CustomerID”];
21 customer.CompanyName = (string)sqlDataReader[“CompanyName”];
22 customers.Add(customer);
23 }
24 }
25 }
26 return customers;
27 }
The GetCustomers() method must meet the following requirements:
connect to a Microsoft SQL Server database.
populate Customer objects with data from the database.
return an IEnumerable<Customer> collection that contains the populated Customer 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 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 throw an InvalidCastException exception if the obj object is not of type
IDataContainer when accessing the Data property. You need to meet the requirements. Which code
segment should you insert at line 07?

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

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


Page 8 of 12« First...678910...Last »