Multiple Choice Question

Quiz Guidelines

 

QID: 
400
Question: 

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 Bird) System.out.println("f is a Bird");
if(e instanceof Flyer) System.out.println("e is a Flyer");
if(b instanceof Flyer) 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 Bird
e is a Flyer
D. f is a Bird
E. e is a Flyer

Q&A Set: 

Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within javajee.com!!!