What should you go?

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 application frameworks. Domain.com operates in the security and surveillance environment. You are currently developing a video surveillance application for Domain.com. While executing your duties, you examine a third party component that implements a Camera class. This class allows you to connect to a physical camera and record video or capture images. The following exhibit illustrates the Camera class definition:

public class Camera
{
public virtual void CaptureImage()
{
//Capture a still image
}
public virtual void StartRecording()
{
//Start a recording session
}
public virtual void StopRecording()
{
//Stop a recording session
}
}

You now need to define the custom class to achieve the following goals:
1. reuse the Camera class to implement a custom class
2. allow the application to capture still images
3. prevent the application from being able to use your class to start and stop a recording session

What should you go? (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 application frameworks. Domain.com operates in the security and surveillance environment. You are currently developing a video surveillance application for Domain.com. While executing your duties, you examine a third party component that implements a Camera class. This class allows you to connect to a physical camera and record video or capture images. The following exhibit illustrates the Camera class definition:

public class Camera
{
public virtual void CaptureImage()
{
//Capture a still image
}
public virtual void StartRecording()
{
//Start a recording session
}
public virtual void StopRecording()
{
//Stop a recording session
}
}

You now need to define the custom class to achieve the following goals:
1. reuse the Camera class to implement a custom class
2. allow the application to capture still images
3. prevent the application from being able to use your class to start and stop a recording session

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

A.
public class StillImageCamera : Camera
{
public override void CaptureImage()
{
base.CaptureImage();
}
}

B.
public class StillImageCamera : Camera
{
public override sealed void StartRecording()
{
base.StartRecording();
}
public override sealed void StopRecording()
{
base.Stoprecording();
}
}

C.
public class StillImageCamera
{
private readonly Camera _camera = new Camera();
public virtual void CaptureImage()
{
_camera.CaptureImage();
}
}

D.
public class StillImageCamera : Camera
{
public new void CaptureImage()
{
base.CaptureImage();
}
}

Explanation:
To allow yourself to be able to control access to the functionality exposed by the Camera class, you should wrap the Camera class by encapsulating it within another class. When you implement only the method that captures still images, you can prevent the application from making use of your class to start or stop a recording session.
Incorrect answers:
A, B, D: To derive a class from the Camera class as suggested in these options is not the solution. This will result in a solution that will allow the application to access all functionality exposed by the Camera class through polymorphism.



Leave a Reply 0

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