Verityprep
Question Bank · Unit 3

AP® Computer Science A Class Creation Multiple Choice Questions

Work through AP Computer Science A multiple-choice questions on Class Creation, then check each answer against a worked solution.

Free · no sign-up Open questions need no account. Sign up or log in to open the rest.

Subtopic: Writing Classes Clear filter

Questions 31–40 of 359
  1. 31
  2. 32
  3. 33
  4. 34
  5. 35
  6. 36
  7. 37
  8. 38
  9. 39
  10. 40

Question 31

Multiple choice Writing Classes
Consider the following method. /** * Precondition: amt represents a positive value in dollars * and cents (for example, 1.15 represents * one dollar…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 32

Multiple choice Writing Classes
Esther wants to write a method swap that swaps two integer values. Which of the following three ways of representing the values and corresponding methods…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 33

Multiple choice Writing Classes
What is the best description of the return value of the method propertyX below? /** Precondition: v.length >= 2 */ public boolean…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 34

Multiple choice Writing Classes
Consider the following two recursive versions of the method choose(n, k). Version 1 public static int choose(int n, int k) { if (k == 0) return 1; else return…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 35

Multiple choice Writing Classes
Consider the following class. public class Question { private boolean answer; public void flip(Question q) { < missing statement > } /* constructors and other…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 36

Multiple choice Writing Classes
Consider the following class definitions: public class Track { private String name; private int duration; public Track(String nm, int dur) { name = nm; duration…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 37

Multiple choice Writing Classes
Consider the following class definitions: Which of the following expressions…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 38

Multiple choice Writing Classes
Consider the following code segment. Track t = new Track("lightning crashes", 200); ArrayList<Track> tracks = new ArrayList<Track>(); // Line ** for (int count…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 39

Multiple choice Writing Classes
Consider the following two classes: Which of the following can replace < missing code > in the CD class's constructor so that it works as specified? I. for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 40

Multiple choice Writing Classes
Consider the following class. public class Counter { private int count = 0; public Counter() { count = 0; } // Line 1 public Counter(int x) { count = x; } //…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 31 of 359
Page 4 of 36