Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
medium Solved by 3 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

orange

D

citrus

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total 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|FAQ