PrepAway - Latest Free Exam Questions & Answers

What should you do?

You work as the Enterprise application developer at Domain.com. The Domain.com network consists of a single Active Directory domain named Domain.com. All servers in the domain run Windows Server 2003. Your responsibilities at Domain.com include the design and development of applications. Domain.com operates as a Geographic Positioning System service provider. You are currently developing a geographical mapping application. You must create a struct named Waypoint that models a waypoint. This waypoint is to consist of a set of latitude and longitude coordinates. In the event of a user passing a street address to the struct, it must perform a location lookup and set its coordinates appropriately.
To this end you need to define the Waypoint struct. You need to ensure that your application requires the least amount of code to set the coordinates from a street address.

What should you do? (Choose the correct code segment.)

PrepAway - Latest Free Exam Questions & Answers

A.
Public Structure Waypoint
Public Latitude As Double
Public Longitude As Double
Public WriteOnly Property Address() As String
Set(ByVal value As String)
‘Set the Latitude and Longitude field based on the address.
End Set
End Property
End Structure

B.
Public Structure Waypoint
Public Latitude As Double
Public Longitude As Double
Public Sub New(ByVal address As String)
‘Set the Latitude and Longitude fields based on the address.
End Sub
End Structure

C.
Public Structure Waypoint
Public Latitude As Double
Public Longitude As Double
Public Function FromAddress(ByVal address As String) As Waypoint Dim waypoint As Waypoint = New Waypoint()
‘Set the Latitude and Longitude fields based on the address.
Return Waypoint
End Function
End Structure

D.
Public Structure Waypoint
Public Latitude As Double
Public Longitude As Double
Public Sub SetAddress(ByVal address As String)
‘Set the Latitude and Longitude fields based on the address.
End Sub
End Structure

Explanation:
When the Waypoint struct is defined with a non-default constructor, it allows calling code to initialize the Latitude and Longitude fields of the Waypoint struct when it is instantiated. This solution only uses one code statement.
Incorrect answers:
A: You should not add a non-static method to return a Waypoint instance. As such it would require applications to first initialize the Waypoint struct by calling its constructor and only then can applications call methods on the structs. Furthermore this solution will require two code statements.
C: You should not add a non-static method to set the Latitude and Longitude fields of the Waypoint instance. This will require the application to first initialize the Waypoint struct by calling its constructor and only then will the application be able to call methods on the struct. Furthermore, this solution will require two code statements.
D: You should not add a property to set the Longitude and Latitude fields of the Waypoint instance. This will require the application to first initialize the Waypoint struct by calling its constructor and only then will the application be able to call methods on the struct. Furthermore, this solution will require two code statements.


Leave a Reply