| preferred AP College board partner for AP classes
AP Computer Science A/Unit 9: Inheritance
Start Practice TestPractice Test
About Exam
easy Solved by 6 students
Inheritance Constructor Call Order
< Prev
Next >

Given the initial execution of the following code:

Lychee l = new Lychee();

If the class hierarchy involves multiple constructor calls each printing a unique statement, determine the output using these classes:

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"); }
}

Which sequence accurately reflects what will be printed out?:

A

Planting a seed
Lychee is sweet

B

Lychee is sweet

C

Growing a fruit
Lychee is sweet
Planting a seed

D

Planting a seed
Growing a fruit
Lychee is sweet

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
#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
No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy