What code segment should you add?
You work as the application developer at Domain.com. Domain.com uses Visual Studio.NET 2005 as its application development platform.
You use a Windwos XP Professional client computer named Certkiller -WS554 as your development computer.
You are developing a .NET Framework 2.0 application on Certkiller -WS554. You write the following code in the application line numbers are for reference only:
01: Public Function ProcCount() As Integer
02: Dim envPerm As EnvironmentPermission = _
03: New EnvironmentPermission( _
04: EnvironmentPermissionAccess.Read, _
05: “NUMBER_OF_PROCESSORS”)
06: ‘Add code segment here
07: Return Environment.ProcessorCount
08: End Function
The ProcCount method in the code will be used to return the number of processors on the computer running the code and the implementation of the method is completely transparent to the callers of the methods. You ensured that the ProcCount method has been granted permission to access environment variables and the callers to the code may not have permission to access the variables. The classes in the other assemblies are required to be able to successfully call the ProcCount method. You must add code at line 06 to override the security check whilst you ensure that any code you write does not affect the permissions that your code already has.
What code segment should you add?
What segment should you add?
You work as the application developer at Domain.com. Domain.com uses Visual Studio.NET 2005 as its application development platform.
You are developing a .NET Framework 2.0 text-processing application. You have access to an array of bytes named ckArray that contains your data.
You are busy writing code that will be used to write the contents of the array to a disk file.
If you are done with the write operation you also display the contents of the stream on the console to make sure that the write operation completes successfully.
The code segment to read and write from the stream is shown below and the line numbers are reference only:
01: Using fStream As FileStream = New FileStream(“ckFile.txt”, FileMode.Create)
02: For i As Integer = 0 To ckArray.Length
03: fStream.WriteByte(ckArray(i))
04: Next i
05: ‘Add code segment here
06: For i As Integer = 0 To fStream.Length
07: Console.WriteLine(fStream.ReadByte())
08: Next i
09: End Using
You add the appropriate code at line 05 to correctly print the contents of the stream.
What segment should you add?
Which code segment should you use?
You need to serialize an object of type List in a binary format.
The object is named data.
Which code segment should you use?
Which code segment should you use?
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?
Which code segment should you use?
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?
Which code segment should you use?
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?
Which code segment should you use?
You need to read the entire contents of a file named Message.txt into a single string variable.
Which code segment should you use?
Which code segment should you use?
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?
Which code segment should you use?
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?
Which code should you use?
You are writing an application that uses SOAP to exchange data with other applications.
You use a Department class that inherits from ArrayList to send objects to another application.
The Department object is named dept.
You need to ensure that the application serializes the Department object for transport by using SOAP.
Which code should you use?