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 service provider in the security industry. You are currently developing a video surveillance application for Domain.com. You need to implement a class named Visuals. Visuals will be destined to control access to a video camera. A method named StartRecording must start a recording session of the camera if one is not already started. In the event of a recording session having started already when the method is called, you must interrupt the execution of the application. To this end you now need to define the Visuals class.

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

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 service provider in the security industry. You are currently developing a video surveillance application for Domain.com. You need to implement a class named Visuals. Visuals will be destined to control access to a video camera. A method named StartRecording must start a recording session of the camera if one is not already started. In the event of a recording session having started already when the method is called, you must interrupt the execution of the application. To this end you now need to define the Visuals class.

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

A.
public class Visuals
{
private bool _recording = false;
public event EventHandler Recording;
public void StartRecording()
{
if(_recording = = true && Recording ! = null)
{
Recording(this, EventArgs.Empty);
}
// Start recording
_recording = true
}
}

B.
public delegate void RecordingStarted(String message); public class Visuals
{
private bool _recording = false;
public RecordingStarted Recording;
public void StartRecording()
{
if (_recording = = true)
{
Recording(“A recording session is in progress.”);
}
// Start recording
_recording = true;
}
}

C.
public class Visuals
{
private bool _recording = false;
public void StartRecording()
{
if (_recording = = true)
{
throw new InvalidOperationException(“A recording session is in progress.”); }
// Start recording
_recording = true;
}
}

D.
public class Visuals
{
private bool _recording = false;
public void StartRecording()
{
if (_recording = = true)
{
MessageBox.Show(“A recording session is in progress.”); }
// Start recording
_recording = true;
}
}

Explanation:
If the method is called when there is already a recording session in progress then you should throw an exception. This will allow you to interrupt the normal flow of an application.
Incorrect answers:
A: Raising an event will result in the application to subscribe to the event to receive notification regarding the status of recording sessions. Thus it will not interrupt the execution of the application.
B: Invoking a delegate is not the solution since it will result in the application to require associating with a method with the delegate to receive notification regarding recording session status and as such would not interrupt the execution of the application.
D: Displaying a message box does not interrupt the execution of an application; it would instead result in an interruption to the user.



Leave a Reply 0

Your email address will not be published. Required fields are marked *