zuai-logo
zuai-logo
  1. AP Computer Science A
FlashcardFlashcardStudy GuideStudy GuideQuestion BankQuestion Bank

Writing Classes in AP Computer Science A

Question 1
college-boardComputer Science AAPExam Style
1 mark

What advantage does using accessor methods provide when comparing a superclass-subclass relationship via inheritance versus utilizing separate classes linked through composition?

Question 2
college-boardComputer Science AAPExam Style
1 mark

In Java, if a field balance is declared as private double balance;, which accessor method signature would be correct?

Question 3
college-boardComputer Science AAPExam Style
1 mark

If a programmer decides to have Class B contain an instance of Class A instead of extending it, what design principle are they likely favoring?

Question 4
college-boardComputer Science AAPExam Style
1 mark

In Java, what should an accessor method return if it's retrieving a boolean instance variable named 'isAvailable'?

Question 5
college-boardComputer Science AAPExam Style
1 mark

In a class where 'items' is an ArrayList storing inventory items, what would be expected from its associated getItemsCount() accessor method?

Question 6
college-boardComputer Science AAPExam Style
1 mark

In Java, which return type would be most appropriate for an accessor method that needs to provide access to a private boolean field named 'isActive'?

Question 7
college-boardComputer Science AAPExam Style
1 mark

When designing a new class for an application, why should you include accessor methods even if all current uses only modify object state?

Feedback stars icon

How are we doing?

Give us your feedback and let us know how we can improve

Question 8
college-boardComputer Science AAPExam Style
1 mark

What is the primary purpose of an accessor method in Java?

Question 9
college-boardComputer Science AAPExam Style
1 mark

Which modifier typically accompanies an accessor method in Java?

Question 10
college-boardComputer Science AAPExam Style
1 mark

Following the naming convention for accessor method, what should the name of the method that returns the value of an instance variable named "count" be?