Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 9: Inheritance
Start Practice TestPractice Test
About Exam
easy Solved by 3 students

Inheritance Constructor Call Order

Mark
< Prev
Next >

Consider the following class definitions.

public class Seed {
   Seed() { System.out.println("Planting a seed"); }
}

public class Fruit extends Seed {
   Fruit() { System.out.println("Growing a fruit"); }
}

public class Lychee extends Fruit {
   Lychee() { System.out.println("Lychee is sweet"); }
}

What is the output when the statement Lychee l = new Lychee(); is executed?

A

Planting a seed
Lychee is sweet

B

Planting a seed
Growing a fruit
Lychee is sweet

C

Lychee is sweet

D

Growing a fruit
Lychee is sweet
Planting a seed

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1zhanghan00311 0m 00s 100
#2zgj0731041711 0m 44s 56
#3parth.taur22711 1m 27s 13
#4meromaroseif01 0m 45s -55
Items per page:
10
1 – 4 of 4

AI Tutor

How can I help?

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