What does the following print?
public class Main { static interface Printable {} static class Rectangle implements Printable {} static class Square extends Rectangle {} public static void main(String[] args) { Rectangle rect = new Square(); Square van = new Square(); Square[] vans = new Square[0]; boolean b = rect instanceof Printable; boolean v = van instanceof Printable; boolean a = vans instanceof Printable[]; System.out.println(b + " " + v + " " + a); } //from w w w. j a va 2 s. c om }
A.
Clearly a Rectangle is a Printable since the Rectangle class implements Printable.
The Square class is also a Printable since it extends Rectangle.
This question also confirms you know that arrays can be tested with instanceof, which they can.
Option A is correct.