.NET Windows Services & Design Patterns

This quiz tests knowledge of Windows Services architecture in .NET and fundamental software design patterns including Observer, Chain of Responsibility, Decorator, and Factory patterns.

20 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Which class does a Windows service always inherit from?

  1. System.ServiceProcess.ServiceInstaller
  2. System.ServiceProcess.ServiceController
  3. System.ServiceProcess.ServiceBase
  4. System.ServiceProcess.ServiceProcessInstaller
Question 2 Multiple Choice (Single Answer)

You want to create a Windows service that will monitor specific folders on the hard drive. This service won't be shared with any other process and will launch when the system is booted. Which configuration would be appropriate for this particular service?

  1. Win32OwnProcess type, Network Service account, automatic startup type
  2. Win32OwnProcess type, LocalSystem account, automatic startup type
  3. Win32OwnProcess type, User account, manual startup type
  4. All
Question 3 Multiple Choice (Single Answer)

Which of the following classes handles the service account type?

  1. ServiceBase
  2. ServiceController
  3. ServiceProcessInstaller
  4. ServiceInstaller
Question 4 Multiple Choice (Single Answer)

Your application is set to start automatically - you stop it using the SCM and restart it. Which sequence of events is triggered from the time the machine is booted?

  1. OnPause, OnStop, OnStart
  2. OnStart, OnStop, OnStart
  3. OnStop, OnContinue
  4. OnStop, OnStart
Question 5 Multiple Choice (Single Answer)

You need to create a source for this service. Which command completes the code? //Add any initialization after the InitializeComponent() callif (!FMEventLog.SourceExists("FileMonitorWS") { FMEventLog. MISSING CODE ("FileMonitorWS", "FMEventLog")}FMEventLog.Source = "FileWS";FMEEventLog.Log = "FMEventLog";

  1. BuildEventSource
  2. CreateEventSource
  3. CallEventSource
  4. All
Question 6 Multiple Choice (Single Answer)

Which switch do you use with the installutil command to uninstall an assembly?

  1. /delete
  2. /remove
  3. /u
  4. /uninstall
Question 7 Multiple Choice (Single Answer)

Why would you choose to create a setup project to install your service?

  1. Service components are spread over several servers
  2. The service uses unmanaged code
  3. You have been unable to install the service manually
  4. You want to distribute the service
Question 8 Multiple Choice (Single Answer)

Which hive of the Registry is used by Windows Services to store their properties?

  1. HKEY_CURRENT_CONFIG
  2. HKEY_CURRENT_USER
  3. HKEY_LOCAL_MACHINE
  4. HKEY_USERS
Question 9 Multiple Choice (Single Answer)

What property name should be added to this code snippet to allow a service to resume after pausing? if (FMServiceController.MISSING CODE) FMServiceController.Continue(); else MessageBox.Show("Service cannot be continued.");

  1. CanContinue
  2. CanPauseAndContinue
  3. CanResume
  4. Continue
Question 10 Multiple Choice (Multiple Answers)

By default, services run in a different security context than that of the logged-in user. Which account types can be specified for a Windows Service?

  1. LocalService
  2. LocalSystem
  3. Administrator
  4. NetworkService
  5. User
Question 11 Multiple Choice (Multiple Answers)

Which can you use to install a Windows Service?

  1. The installutil command
  2. The Service Control Manager
  3. The Windows Registry
  4. Windows Installer file (.msi)
Question 12 Multiple Choice (Multiple Answers)

What actions can you accomplish using the Services Control Manager?

  1. Changing service descriptions
  2. Creating service installation projects
  3. Starting and stopping services
  4. Uninstalling services
Question 13 Multiple Choice (Multiple Answers)

Suppose you were programmatically creating a component to control the FileWatch service on a local EasyNomad machine. Which options are correct?

  1. private ServiceController FMServiceController = new ServiceController ('EasyNomad') ;
  2. private ServiceController FMServiceController = new ServiceController ('EasyNomad', 'FileWatch') ;
  3. private ServiceController FMServiceController = new ServiceController ('FileWatch', 'EasyNomad') ;
  4. private ServiceController FMServiceController = new ServiceController(“FileWatch”) ;
Question 14 Multiple Choice (Multiple Answers)

What are the ways of creating a ServiceController component instance?

  1. Adding the ServiceController component from the Services Control Manager
  2. Adding the ServiceController component from the Toolbox
  3. Adding the ServiceController component to the Designer from Server Explorer
  4. Using manually entered code
Question 15 Multiple Choice (Multiple Answers)

Which of these steps are required to debug an entire Windows service?

  1. Attaching the debugger to the service process
  2. Creating a dummy service to call the service
  3. Starting a dummy service
  4. Starting both services
Question 16 Multiple Choice (Multiple Answers)

What properties would you set to True for a service that can restart after being paused and which writes information to the Application log?

  1. CanShutDown
  2. CanPauseAndContinue
  3. AutoLog
  4. CanStop
Question 17 Multiple Choice (Single Answer)

Provides a simple decision making class which returns one of several possible subclasses of an abstract base class depending on data it is provided

  1. Factory Pattern
  2. Abstract Factory Pattern
  3. Builder Pattern
  4. Prototype Pattern
Question 18 Multiple Choice (Single Answer)

A class that surrounds a given class, adds new capabilities to it, and passes all the unchanged methods to the underlying class

  1. Flyweight Pattern
  2. Façade Pattern
  3. Composite Pattern
  4. Decorator Pattern
Question 19 Multiple Choice (Single Answer)

This pattern allows decoupling between classes, by passing a request between classes until it is recognized

  1. Adapter Pattern
  2. Observer Pattern
  3. Chain of Responsibility Pattern
  4. Strategy Pattern
Question 20 Multiple Choice (Single Answer)

Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically

  1. Visitor Pattern
  2. Notifier Pattern
  3. Observer Pattern
  4. Template Pattern