Create a Java program to demonstrate the use of an interface for custom document printing
interface DocumentPrinter { void printDocument(String document); void cancelPrinting(); } public class Main { public static void main(String[] args) { DocumentPrinter documentPrinter = new DocumentPrinter() { @Override public void printDocument(String document) { System.out.println("Printing document : " + document);// Implement document printing logic here } @Override public void cancelPrinting() { System.out.println("Document printing canceled");// Implement cancel printing logic here } }; String document = "Sample Document"; documentPrinter.printDocument(document);// Print document documentPrinter.cancelPrinting();// Cancel printing } }
Printing document : Sample Document Document printing canceled
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions