Practice Questions

Question 1

You are printing the first page of a two-page document and want to fire the PrintPage event for the second page. How can you do this with the least amount of effort?

  • A. Set the HasMorePages property to False.

  • B. Set the HasMorePages property to True.

  • C. Perform a simple loop, instantiating the PagePrint method for each page in order.

  • D. Place two PrintDocument components within the application and link each to the appropriate page.

A1:

Answer B is correct. When you set the HasMorePages property to True, the PrintDocument component will generate the next page's output. Answer A is incorrect because setting the HasMorePages property to False would tell the component there are no more pages to print. Answers C and D are incorrect because they involve far more effort and may limit later application expansion to include reports with more than two pages.

Question 2

Which events fire once for each page to be printed? [Select all that apply.]

  • A. BeginPrint

  • B. QueryPageSettings

  • C. PrintPage

  • D. EndPrint

A2:

Answers B and C are correct. The QueryPageSettings and PrintPage events both fire once for each printed page. Answer A is incorrect because the BeginPrint event fires once before the entire print job, and answer D is incorrect because the EndPrint event fires once after the entire job is done.

Question 3

You are printing an image that includes color , but the target printer is a black-and-white laser printer. What must you do to restrict the colors to only those the printer can handle?

  • A. Use the System.Drawing classes to translate the image to a black-and-white version.

  • B. Use the PrintDialog class to prompt the user for a different printer.

  • C. Use the PrintDocument class to print the image.

  • D. Use the PictureBox class to translate the image to a black-and-white version.

A3:

Answer C is correct. Although you can control whether the generated output will include color, this is not necessary. Windows will automatically restrict color output to only those supported by the target printer. Therefore, answers A, B, and D are all incorrect.

Question 4

You need to configure printed output based on data you will acquire from a single SQL query, but you need to separate the data by page. In which event should you place the SQL call?

  • A. BeginPrint

  • B. QueryPageSettings

  • C. PrintPage

  • D. EndPrint

A4:

Answer A is correct. You should use the BeginPrint event to perform preloading tasks that will be used for the entire print job. Answers B and C are incorrect because the QueryPageSettings and PrintPage events fire once for each page and would generate multiple hits against your SQL server, thus increasing the network and system load. Answer D is incorrect because the EndPrint event only fires after all pages have been printed.

Question 5

You want to make sure that a report is always generated in Portrait mode. Which of the following will fulfill this requirement?

  • A. Set the Bounds property of the PageSettings class to True.

  • B. Set the Portrait property of the PageSettings class to True.

  • C. Set the Landscape property of the PageSettings class to False.

  • D. Set the Orientation property of the PageSettings class to Landscape.

A5:

Answer C is correct. When you set the Landscape property of the PageSettings class to False, the output is forced to Portrait mode. Answer A is incorrect because the Bounds property defines the available space based on the paper orientation rather than the orientation itself. Answers B and D are incorrect because they do not specify valid properties of the PageSettings class.

Question 6

Users report that their printouts are not properly formatted because of the mixture of fonts used. Which method can you use to determine the proper number of lines that will fit on the page?

  • A. GetHeight

  • B. Print

  • C. OnBeginPrint

  • D. ShowDialog

A6:

Answer A is correct. You can use the GetHeight method to get the height of any piece of text. By summing per-line values calculated using the GetHeight method to measure font size, it is possible to determine whether a new page is required or whether a line of text will fit in the remaining space. Answers B, C, and D are all incorrect.

Question 7

You need to create an Event Log entry for each print job that details the number of pages in a print job, along with a code that indicates whether any errors occurred during page formatting for any of the pages. Where should you place the code for this requirement?

  • A. BeginPrint

  • B. QueryPageSettings

  • C. PrintPage

  • D. EndPrint

A7:

Answer D is correct. An Event Log entry that includes details spanning an entire print job should be generated within the EndPrint event, which fires after the job is completed. You would need to add code necessary to handle any errors, setting some type of flag to allow later specification of the error condition in the Event Log entry. Answer A is incorrect because the BeginPrint event fires before any pages have been printed. Answers B and C are incorrect because the QueryPageSettings and PrintPage events fire once for every page that is generated and would result in multiple Event Log entries.

Question 8

You want to allow your users to check the way the printed output will look before they waste paper printing lengthy reports. They need to be able to vary the zoom to allow close detail inspection of graphic images. Which elements can be used to support this requirement? [Select all that apply.]

  • A. PageSetupDialog

  • B. PrintPreviewDialog

  • C. PrintPreviewControl

  • D. PrintDialog

A8:

Answers B and C are correct. Both the PrintPreviewDialog and PrintPreviewControl elements may be used to support the requirement for print preview, although the PrintPreviewControl control will require additional code in order to manage the need for a variable zoom. Answer A is incorrect because the PageSetupDialog component is used to control page settings, and answer D is incorrect because the PrintDialog component is used to control printer settings.

Question 9

You need to create a printed page that contains both text and graphic data. Which class can you use to perform the printing?

  • A. Bitmap

  • B. PrintDocument

  • C. PrintDialog

  • D. Form

A9:

Answer C is correct. The PrintDocument class supports printing both text and graphic elements through the extension of the System.Drawing namespace. Answer A is incorrect because the Bitmap class does not help you print text data. Answer C is incorrect because the PrintDialog class handles printer setup, not printing. Answer D is incorrect because you cannot directly print a form.

Question 10

You have been tasked with saving paper in the many lengthy print jobs that are routinely generated. Which property of the PrinterSettings class should you use to directly support this requirement, assuming that the printer supports all properties?

  • A. CanDuplex

  • B. Collate

  • C. Copies

  • D. Duplex

A10:

Answer D is correct. The Duplex property can be used to cause printouts to occur on both sides of each page, thus reducing the number of pages of paper by half. Answer A is incorrect because the CanDuplex property returns a value based on whether the printer supports duplex printing or not. Answer B is incorrect because collating the output simply involves the manner in which the resulting pages are ordered. Answer C is incorrect because the requirement does not include a specification that the number of copies of each report should be modified, so this is not the best answer of those provided.



Developing and Implementing WindowsR-based Applications with Visual BasicR. NET and Visual StudioR. NET Exam CramT 2 (Exam 70-306)
Developing and Implementing WindowsR-based Applications with Visual BasicR. NET and Visual StudioR. NET Exam CramT 2 (Exam 70-306)
ISBN: N/A
EAN: N/A
Year: 2002
Pages: 188

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net