Multiple Choice Question

Quiz Guidelines



Consider the following code:

interface Flyer{ }
class Bird implements Flyer { }
class Eagle extends Bird { }
class Bat { }
public class TestClass {
public static void main(String[] args) {
Flyer f = new Eagle();
Eagle e = new Eagle();
Bat b = new Bat();
if(f instanceof Flyer) System.out.println("f is a Flyer");
if(e instanceof Bird) System.out.println("e is a Bird");
if(b instanceof Bird) System.out.println("f is a Bird");

What will be printed when the above code is compiled and run?

Select 1 option

A. It will not compile.
B. It will throw an exception when run.
C. f is a Flyer
    e is a Bird
D. f is a Flyer
E. e is a Bird

Q&A Set: