Printing in Java

The original JDK 1.0 release did not provide any printing support.  The release of the 1.1 version of the Java Developer's Kit in 1997 provided Java developers with a basic framework for printing from applications. Java provides classes for printing on printer through Java 2D printing API. The Java 2D printing API is not limited to printing graphics. It enables user to print the content of an application's user interface as well. The main classes and interfaces involved in printing are represented in the java dot a-w-t dot print and java-x dot print packages.

The basic printing operations performed by Java Printing API are Creating print job and Readying printer for print job. To print, a client initiates a print job by obtaining a new instance of Print Job. The print job is a unit of work to be run on printer, decided by the application using printing API. Every print job is assigned a job number when received and severed according to the job number. Deciding the print job once, application can send strips of page instead of the whole page to the printer. The application only needs to know how to render the print job. There are two printing models in Java: Printable jobs and Pageable jobs.

To Access the full content, Please Purchase

  • Q1

    To which class or interface method print() belongs?

    Marks:1
    Answer:

    Method print() belongs to interface “Printable”.

    View Answer
  • Q2

    Name the interface of java.awt.print package.

    Marks:1
    Answer:

    There are three interfaces in java.awt.print package and they are:
    1. Printable
    2. Pageable
    3. PrinterGraphics

    View Answer
  • Q3

    What is NO_SUCH_PAGE? Where is it used?

    Marks:1
    Answer:

    NO_SUCH_PAGE is a constant value returned by PagePrinter in printable printing model when the last page is printed.

    View Answer
  • Q4

    Name the printing models in Java.

    Marks:1
    Answer:

    The different printing models in Java are:
    · Printable
    · Pageable

    View Answer
  • Q5

    Which Java package contains classes and interfaces used for printing?

    Marks:1
    Answer:

    java.awt.print package contains classes and interfaces used for printing.

    View Answer