Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Code example 9-1 public interface Printable { public void print(); } public clas

ID: 654139 • Letter: C

Question

Code example 9-1
public interface Printable
{
    public void print();
}

public class Printer
{
    public static void printInvoice(Printable p)
    {
        System.out.println("Printing invoice...");
        p.print();
    }
}

public class Order implements Printable
{
    public void print()
    {
        System.out.println("Order object");
    }
}

public class Rental extends Transaction implements Printable
{
    public void print()
    {
        System.out.println("Rental object");
    }
}

(Refer to code example 9-1.) What happens when the code that follows is executed?
Rental rental = new Rental();
Printer.printInvoice(rental);

a.

Explanation / Answer

solution:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote