Multiple Choice Question

Quiz Guidelines

 

QID: 
216
Question: 

Consider the following code:

interface Flyer{ String getName(); }
class Bird implements Flyer{
public String name;
public Bird(String name){
this.name = name;
}public String getName(){ return name; }
}
class Eagle extends Bird {
public Eagle(String name){
super(name);
}
}public class TestClass {
public static void main(String[] args) throws Exception {
Flyer f = new Eagle("American Bald Eagle");          //PRINT NAME HERE
}  }

Which of the following lines of code will print the name of the Eagle object?

Select 3 options

A. System.out.println(f.name);
B. System.out.println(f.getName());
C. System.out.println(((Eagle)f).name);
D. System.out.println(((Bird)f).getName());
E. System.out.println(Eagle.name);
F. System.out.println(Eagle.getName(f));

Q&A Set: 

Search the Web

Custom Search

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