Given:
interface Fish {
}
class Perch implements Fish {
}
class Walleye extends Perch {
}
class Bluegill {
}
public class Fisherman {
public static void main(String[] args) {
Fish f = new Walleye();
Walleye w = new Walleye();
Bluegill b = new Bluegill();
if (f instanceof Perch)
System.out.print(“f-p “);
if (w instanceof Fish)
System.out.print(“w-f “);
if (b instanceof Fish)
System.out.print(“b-f “);
}
}
What is the result?
A.
w-f
B.
f-p w-f
C.
w-f b-f
D.
f-p w-f b-f
E.
Compilation fails.
F.
An exception is thrown at runtime.
Explanation:
f-p w-f
B