| preferred AP College board partner for AP classes
AP Computer Science A/Unit 9: Inheritance
Start Practice TestPractice Test
About Exam
medium Solved by 7 students
Polymorphic Method Call Output
< Prev
Next >

Consider the following class declarations.

public class Fruit {
    public String flavor() { return "generic"; }
}

public class Orange extends Fruit {
    public String flavor() { return "citrus"; }
    public String color() { return "orange"; }
}

public class TestFruit {
    public static void main(String[] args) {
        Fruit f = new Orange();
        System.out.println(f.flavor());
    }
}

What is printed when the main method in the TestFruit class is executed?

A

Compilation Error

B

generic

C

citrus

D

orange

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1kaisuki11 0m 00s 100
#2suhanakochhar00611 0m 44s 56
#3psak1211 1m 30s 10
Items per page:
10
1 – 3 of 3
No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy