1. Question: You are creating a class that performs complex financial calculations.
    The class contains a method named GetCurrentRate that retrieves the current interest rate and
    a variable
    named currRate
    that stores the current interest rate.
    You write serialized representations of the class.
    You need to write a code segment that updates the currRate variable with the current interest
    rate
    when an instance of the class is deserialized.
    Which code segment should you use? - (VB.Net)

    A
    <OnSerializing> _
    Friend Sub UpdateValue(context As StreamingContext)
    currRate = GetCurrentRate()
    End Sub

    B
    <OnSerializing> _
    Friend Sub UpdateValue(info As SerializationInfo)
    info.AddValue("currentRate", GetCurrentRate())
    End Sub

    C
    <OnDeserializing> _
    Friend Sub UpdateValue(info As SerializationInfo)
    info.AddValue("currentRate", GetCurrentRate())
    End Sub

    D
    <OnDeserialized> _
    Friend Sub UpdateValue(context As StreamingContext)
    currRate = GetCurrentRate()
    End Sub

    Note: Not available
    1. Report
  2. Question: You are writing an application that uses isolated storage to store user preferences.
    The application uses multiple assemblies.
    Multiple users will use this application on the same computer.
    You need to create a directory named Preferences in the isolated storage area that is scoped to
    the current
    Microsoft Windows identity and assembly.
    Which code segment should you use? - (VB.Net)

    A
    Dim store As IsolatedStrongFile
    store = IsolatedStorageFile.GetUserStoreForAssembly()
    store.CreateDirectory("Preferences")

    B
    Dim store As IsolatedStrongFile
    store = IsolatedStorageFile.GetStoreForAssembly()
    store.CreateDirectory("Preferences")

    C
    Dim store As IsolatedStrongFile
    store = IsolatedStorageFile.GetUserStoreForDomain()
    store.CreateDirectory("Preferences")

    D
    Dim store As IsolatedStrongFile
    store = IsolatedStorageFile.GetMachineStoreForApplication()
    store.CreateDirectory("Preferences")

    Note: Not available
    1. Report
  3. Question: You need to read the entire contents of a file named Message.txt into a single string variable.
    Which code segment should you use? - (VB.Net)

    A
    Dim result As String = Nothing
    Dim reader As New StreamReader("Message.txt")
    result = reader.Read().ToString()

    B
    Dim result As String = Nothing
    Dim reader As New StreamReader("Message.txt")
    result = reader.ReadToEnd()

    C
    Dim result As String = String.Empty
    Dim reader As New StreamReader("Message.txt")
    While Not reader.EndOfStream
    result += reader.ToString()
    End While

    D
    Dim result As String = Nothing
    Dim reader As New StreamReader("Message.txt")
    result = reader.ReadLine()

    Note: Not available
    1. Report
  4. Question: You need to write a code segment that transfers the first 80 bytes from a stream variable named
    stream1
    into a new byte array named byteArray.
    You also need to ensure that the code segment assigns the number of bytes that are
    transferred to an
    integer variable
    named bytesTransferred.
    Which code segment should you use? - (VB.Net)

    A
    bytesTransferred = stream1.Read(byteArray, 0, 80)

    B
    For i As Integer = 0 To 79
    stream1.WriteByte(byteArray(i))
    bytesTransferred = i
    If Not stream1.CanWrite Then
    Exit For
    End If
    Next

    C
    While bytesTransferred < 80
    stream1.Seek(1, SeekOrigin.Current)
    byteArray(System.Math.Max(System.Threading.Interlocked.Increment(bytesTransferred),
    bytesTransferred - 1)) = Convert.ToByte(stream1.ReadByte())
    End While

    D
    stream1.Write(byteArray, 0, 80)
    bytesTransferred = byteArray.Length

    Note: Not available
    1. Report
  5. Question: You are writing a method that accepts a string parameter named message.
    Your method must break the message parameter into individual lines of text and pass each line
    to a second
    method named Process.
    Which code segment should you use? - (VB.Net)

    A
    Dim reader As New StringReader(message)
    Process(reader.ReadToEnd())
    reader.Close()

    B
    Dim reader As New StringReader(message)
    While reader.Peek() <> -1
    Dim line As String = reader.Read().ToString()
    Process(line)
    End While
    reader.Close()

    C
    Dim reader As New StringReader(message)
    Process(reader.ToString())
    reader.Close()

    D
    Dim reader As New StringReader(message)
    While reader.Peek() <> -1
    Process(reader.ReadLine())
    End While
    reader.Close()

    Note: Not available
    1. Report
  6. Question: You need to write a code segment that transfers the contents of a byte array named
    dataToSend
    by using a NetworkStream object named netStream.
    You need to use a cache of size 8,192 bytes.
    Which code segment should you use? - (VB.Net)

    A
    Dim memStream As New MemoryStream(8192)
    memStream.Write(dataToSend, 0, CInt(netStream.Length))

    B
    Dim memStream As New MemoryStream(8192)
    netStream.Write(dataToSend, 0, CInt(memStream.Length))

    C
    Dim bufStream As New BufferedStream(netStream, 8192)
    bufStream.Write(dataToSend, 0, dataToSend.Length)

    D
    Dim bufStream As New BufferedStream(netStream)
    bufStream.Write(dataToSend, 0, 8192)

    Note: Not available
    1. Report
  7. Question: You need to serialize an object of type List<int> in a binary format.
    The object is named data.
    Which code segment should you use? - (VB.Net)

    A
    Dim formatter As New BinaryFormatter()
    Dim stream As New MemoryStream()
    formatter.Serialize(stream, data)

    B
    Dim formatter As New BinaryFormatter()
    Dim stream As New MemoryStream()
    For i As Integer = 0 To data.Count - 1
    formatter.Serialize(stream, data(i))
    Next

    C
    Dim formatter As New BinaryFormatter()
    Dim buffer As Byte() = New Byte(data.Count - 1) {}
    Dim stream As New MemoryStream(buffer, True)
    formatter.Serialize(stream, data)

    D
    Dim formatter As New BinaryFormatter()
    Dim stream As New MemoryStream()
    data.ForEach(Function(num As Integer) Do
    formatter.Serialize(stream, num)
    End Function)

    Note: Not available
    1. Report
  8. Question: Certkiller.com has given you the task of serializing an object and writing it to a data file using
    binary
    serialization.
    You need to ensure that you meet these requirements.
    What should you do? - (VB.Net)

    A
    Use the following code:
    Dim obj As New Object()
    Dim objSream As Stream = File.Open("DataFile.dat", FileMode.Create)
    Dim objFormatter As New BinaryFormatter()
    objFormatter.Serialize(objStream, obj)

    B
    Use the following code:
    Dim obj As New Object()
    Dim objFormatter As New BinaryFormatter()
    objFormatter.Serialize(obj)

    C
    Use the following code:
    Dim objSream As Stream = File.Open("DataFile.dat", FileMode.Create)
    Dim objFormatter As New BinaryFormatter()
    objFormatter.Serialize(objStream)

    D
    Use the following code:
    Dim obj As New Object()
    Dim objSream As Stream = File.Open("DataFile.dat", FileMode.Create)
    Dim objFormatter As New BinaryFormatter()
    objFormatter.Serialize(obj, objStream)

    Note: Not available
    1. Report
  9. Question: You have recently created a serializable class named Vehicle.
    The class is shown below:
    <Serializable> _
    Public Class Vehicle
    Public VIN As String
    Public Make As String
    Public Model As String
    Public Year As String
    End Class
    You are planning to create a custom formatter class to control the formatting of Vehicle objects
    when they
    are serialized.
    You need to ensure that is achieved with as little development effort as possible.
    What should you do? - (VB.Net)

    A
    Use the following code:
    Public Class VehicleFormatter
    Inherits Formatter
    'Implementation omitted
    End Class

    B
    Use the following code:
    Public Class VehicleFormatter
    Implements IGenericFormatter
    'Implementation omitted
    End Class

    C
    Use the following code:
    Public Class VehicleFormatter
    Implements IFormatConverter
    'Implementation omitted
    End Class

    D
    Use the following code
    Public Class VehicleFormatter
    Implements IFormatter
    'Implementation omitted
    End Class

    Note: Not available
    1. Report
  10. Question: You develop a serializable class for persisting objects as files.
    Every time an object is serialized, you have to update the database with the name of the object
    and location
    of that file.
    You elect to employ the OnSerialized attribute to achieve this objective.
    You now need to apply the OnSerialized attribute to a certain method.
    What should you do? - (VB.Net)

    A
    Apply the OnSerialized attribute to the following method:
    Public Sub AfterSerialization(sender As Object, e As SerializationEventArgs)
    'Update database
    End Sub

    B
    Apply the OnSerialized attribute to the following method:
    Public Sub AfterSerialization(sender As Object)
    'Update database
    End Sub

    C
    Apply the OnSerialized attribute to the following method:
    Public Sub AfterSerialization(context As StreamingContext)
    'Update database
    End Sub

    D
    Apply the OnSerialized attribute to the following method:
    Public Function AfterSerialization() As StreamingContext
    'Update database
    End Function

    Note: Not available
    1. Report
Copyright © 2024. Powered by Intellect Software Ltd