Chapter 5 Flashcards

1
Q

What is a Windows Forms Application?

A

Windows Forms Application - smart client applications that consist of one or more forms, displaying a visual interface to the user. They integrate well with the OS, use connected devices and can work whether connected to the internet or not.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a Windows Form?

A

Windows Form - visual surface capable of displaying a variety of controls. Visual Studio provides a drag and drop Windows Forms designer to easily create applications.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a control?

A

Control - distinct user interface element that accepts input from or displays output to the user.

Forms provide a built in collection of controls, can also add custom controls or 3rd party controls.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is event handling in a UI programme?

A

Event handling plays key role in user interface based programming. Respond to various events that are fired from user actions to make programs interactive.

Windows Forms applications form and controls expose a set of predefined events. When event occurs, the code associated with the event handler is invoked.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the syntax for adding a delegate?

A

Syntax for adding a delegate is += operator. This is due to fact .NET supports multicast delegates in which a delegate can be bound to more than one method. This allows one to many notifications when an event is fired.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is visual inheritance?

A

Visual Inheritance - allows you to reuse existing functionality and layout for Windows Forms.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What event model does Windows Forms use?

A

Windows forms event model uses the .NET Framework delegates to bind events to respective event handler.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How does visual inheritance apply to a Windows Form?

A

Windows Form is essentially another class therefore inheritance applies to it. However when applied to a Windows Form, it causes the inheritance of all visual characteristics of the form such as size, colour and controls placed on it. You can visually manipulate the properties that are inherited from base class and is often called visual inheritance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a Multiple Document Interface?

A

Multiple Document Interface (MDI) - applications in which multiple child windows reside under a single parent window. They allow multiple windows to share a single application menu and toolbar e.g. Excel with multiple worksheets open.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a Single Document Interface?

A

Single Document Interface (SDI) - each window contains its own menu and toolbar, rely on the OS to provide window management e.g. Windows switching among multiple windows in the taskbar.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Can programs make use of both a MDI and SDI?

A

Yes, many application make use of both MDI and SDI e.g. Word opens in SDI but allows users to open multiple windows.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What property must be set for a parent form in a MDI?

A

In code important to set the IsMdiContainer property to true for parent form.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What property must be set for each child form in a MDI?

A

Each child form must set the MdiParent property to specify the parent form.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the purpose of the MdiWindowListItem property?

A

MdiWindowListItem property of the menu strip indicates which menu item will display list of child windows.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the LayoutMdi method used to achieve?

A

LayoutMdi method is used by menu items in the Window to arrange the child windows e.g. tiled horizontally or vertically, cascaded or as icons.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are console based applications?

A

Console based applications - do not have a graphical user interface and use a text mode console window to interact with the user.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Where are console based applications run from?

A

Console based application run from console window.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

How do you input and output in a console based application?

A

Input via command line parameters.

Output written to command window as well.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What are windows services?

A

Windows service is an application that runs in the background and does not have any user interface.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What kind of services are Windows Services?

A

Usually a long running process that do not provide direct user interaction, can be started, paused, restarted and stopped.Examples include Web server listening for incoming requests or print spooler.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Where must all Windows Services derive from?

A

All Windows Services must derive from the ServiceBase class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What methods of the Service base class can be overridden?

A

Can override base class OnStart, OnStop, OnPause and OnContinue methods.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What properties determine if a service needs to override the base class methods?

A

CanPauseAndContinue and CanShutdown properties determine if a service needs to override base class methods such as OnStart, onStop, OnPause.

24
Q

What does the WriteEntry method do?

A

WriteEntry method takes the message, type of event log entry (information, warning etc) and an eventId and writes it to the log.

25
Q

How is a Windows Service installed?

A

A windows service must be installed in the Windows service database by adding a Service Installer to the Windows service project.

26
Q

What is the StartType property of the ServiceInstaller class?

A

StartType property of the ServiceInstaller class indicates how and when a service is started has 3 values: Manual, Automatic or Disabled.

27
Q

Which classes does the Windows Service installer add?

A

Windows Service installer adds the ServiceProcessInstaller and ServiceInstaller classes.

28
Q

What does the ServiceProcessInstaller class do?

A

ServiceProcessInstaller - performs tasks common to all Windows services such as setting login account for the service.

29
Q

What is the purpose of the ServiceProcessInstaller class?

A

ServiceProcessInstaller - performs tasks specific to a single Windows service e.g. ServiceName.

30
Q

What does the account property of ServiceProcessInstaller class?

A

Account property of ServiceProcessInstaller specifies type of account under which the service runs either LocalService, LocalSystem NetworkService and User.

31
Q

What is the difference in the LocalSystem and LocalService accounts?

A

LocalSystem is a highly privileged account whereas LocalService is a non-privileged account.

32
Q

Which account type must you not use on a Windows Service?

A

Should not use LocalSystem account for running a Windows Service.

33
Q

You need to design a Windows service that cannot be paused. Which of the following options will help you accomplish this task?

a. Set the CanPauseAndContinue property of the Windows service to False.
b. Set the CanPauseAndContinue property of the Windows service to True.
c. Set the CanStart property of the Windows service to True, but set the CanShutdown property to False.
d. Do not override the OnPause and OnContinue methods in the Windows service.

A

a. Set the CanPauseAndContinue property of the Windows service to False.

34
Q

You have developed a Windows service and need to install this service in order to install its functionality. Which of the following options should you choose to accomplish this task?

a. Use the Visual Studio Server Explorer.
b. User the Services node in the Computer Management window.
c. Use InstallUtil.exe.
d. Use gacutil.exe.

A

c. Use InstallUtil.exe.

35
Q

You have developed a Windows service. This service needs to run as a nonprivileged user in order to minimize any possible security risk. Which of the following accounts should you use for running this Windows service?

a. LocalSystem
b. NetworkService
c. LocalService
d. User (where the UserName property is set to a member of administrator role)

A

c. LocalService

36
Q

You are designing a Windows service application that contains only one Windows service. You would like this service to be started automatically when the computer is restarted. Which of the following classes should you use to specify this setting?

a. ServiceBase
b. ServiceInstaller
c. ServiceProcessInstaller
d. ServiceController

A

b. ServiceInstaller

37
Q

You need to change the display and behavior of a Windows Form so that the form can contain multiple child windows. What should you do?

a. Set the IsMdiContainer property of the form to True.
b. Set the MdiParent property for all the child windows.
c. Set the MdiChild property of the form.
d. Set the IsMdiChild property of the form.

A

a. Set the IsMdiContainer property of the form to True.

38
Q

You are developing a Windows Form that responds to mouse events. When the mouse moves, you need to invoke the method Form1_HandleMouse. Any code that you write should not affect any existing event-handling code. What statement should you use to attach the event handler to the event?

a.
this.MouseDown = new MouseEventHandler
(Form1_HandleMouse);
b.
this.MouseMove = new MouseEventHandler
(Form1_HandleMouse);
c.
this.MouseDown += new MouseEventHandler
(Form1_HandleMouse);
d.
this.MouseMove += new MouseEventHandler
(Form1_HandleMouse);

A

d.
this.MouseMove += new MouseEventHandler
(Form1_HandleMouse);

39
Q
You are developing a Windows form with a multiple document interface (MDI). You need to write code that arranges the child windows vertically within the client region of the MDI parent form. Which of the following statements should you use?
a.	
LayoutMdi(MdiLayout.TileVertical);
b.	
LayoutMdi(MdiLayout.Cascade);
c.	
MdiLayout(LayoutMdi.TileVertical);
d.	
MdiLayout(LayoutMdi.Cascade);
A

a.

LayoutMdi(MdiLayout.TileVertical);

40
Q

You are developing an application that will be run from the command line. Which of the following methods would you use for output to the command line?

a. Console.Read
b. Console.Write
c. File.Read
d. File.Write

A

b. Console.Write

41
Q

You want to develop an application that displays a visual surface capable of displaying a variety of controls, such as text boxes, buttons, and menus. The application should also allow multiple child windows to reside under a single parent window. Which of the following types of applications should you develop?

a. Console-based application.
b. Windows service application.
c. Single document interface (SDI) application.
d. Multiple document interface (MDI) application.

A

d. Multiple document interface (MDI) application.

42
Q

You are extending an existing Windows application. You would like to create a new form that derives its visual characteristics (including size, color, and some controls) from a previously created form. Which technique should you use to create the new form?

a. Visual inheritance.
b. Visual encapsulation.
c. Visual abstraction.
d. Visual polymorphism.

A

a. Visual inheritance.

43
Q

Use the ________ property of the ServiceInstaller class to specify a brief comment that explains the purpose of the service.

A

Description

44
Q

The ________ property of the __________ class indicates the account type under which a Windows service will run.

A

Account, ServiceProcessInstaller

45
Q

The ______ property of the EventLog class is use to specify the application name to use when writing to an event log.

A

Source

46
Q

__________ allows you to reuse existing functionality and layout for Windows Forms.

A

Visual inheritance

47
Q

______________ applications are applications in which multiple child windows reside under a single parent window.

A

Multiple document interface (MDI)

48
Q

A(n) __________ is ideal for creating long-running applications that run in the background and do not have any user interface.

A

Windows service

49
Q

_____________ do not have a graphical user interface and use a text-mode console window to interact with the user.

A

Console-based applications

50
Q

______________ applications provide their own window management functionality, whereas ______________ applications rely on the operating system for window management.

A

Multiple document interface (MDI),

single document interface (SDI)

51
Q

A delegate can be bound to any method whose signature matches that of the ____________.

A

delegate declaration

52
Q

The _______________ can be bound to more than one method, allowing one-to-many notifications when an event is fired.

A

multicast delegates

53
Q

ExecuteScalar?

A

Return 1 record / result

54
Q

ExecuteNonQuery?

A

Insert / deleting or updating (fastest way)

55
Q

ExecuteReader?

A

Retrieve records.