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
medium Solved by 1 students

Java Inheritance and Constructors

< Prev
Next >

Consider the following class declarations.

public class FruitBasket {
   private int appleCount;
  FruitBasket () {
    appleCount = 1;
   }
  FruitBasket(int count) {
    appleCount = count;
   }
   public int getAppleCount () {
    return appleCount;
   }
}
public class AppleBag extends FruitBasket {
  AppleBag () {
    super(3);
  }
}

Which of the following code segments will compile without error?

A

AppleBag a2 = new FruitBasket();

B

AppleBag a1 = new AppleBag(4);

C

FruitBasket f1 = new AppleBag(2);

D

FruitBasket f2 = new AppleBag();

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

Question Leaderboard

Not enough data yet to show leaderboard.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

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