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

public interface Printable { public void print(); } public class Printer { publi

ID: 3711818 • Letter: P

Question

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 given above) Which of the following statements will definitely not compile?

A) Printable p = new Order();

B) Rental rental = new Rental();
Printable p = rental;

C) Printable p = new Printable();

D) Transaction t = new Rental();

A) Printable p = new Order();

B) Rental rental = new Rental();
Printable p = rental;

C) Printable p = new Printable();

D) Transaction t = new Rental();

Explanation / Answer

C) Printable p = new Printable();

reason : we cannot instantiate an interface or abstract class in java and Printable is an interface.