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 151–160 of 359
  1. 151
  2. 152
  3. 153
  4. 154
  5. 155
  6. 156
  7. 157
  8. 158
  9. 159
  10. 160

Question 151

Multiple choice Writing Classes
A car dealer needs a program that will maintain an inventory of cars on his lot. There are four types of cars: sedans, station wagons, electric cars, and SUVs.…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 152

Multiple choice Writing Classes
public class Card { private String suit; private int value; //0 to 12 public Card(String cardSuit, int cardValue) {/* implementation */ } public String…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 153

Multiple choice Writing Classes
Consider the NegativeReal class below, which defines a negative real number object. public class NegativeReal { private Double negReal; /** Constructor. Creates…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 154

Multiple choice Writing Classes
Consider the following class Test with an incomplete main method: public class Test { private static int year = 2020; public Test(int yr) { year = yr; } public…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 155

Multiple choice Writing Classes
Consider the following class: public class Monster { private String x; public void feed(String number) { if (x == null || x.compareTo(number) < 0) { x = number;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 156

Multiple choice Writing Classes
Consider the following class definition: public class BankAccount { private double balance; public BankAccount(double initialBalance) { balance =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 157

Multiple choice Writing Classes
Consider the following incomplete class definition: public class Student { private int id; // other fields, constructors, and methods not shown } Suppose we…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 158

Multiple choice Writing Classes
Consider the following method fun2. public int fun2(int x, int y) { y -= x; return y; } What are the values of the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 159

Multiple choice Writing Classes
Suppose a class MyTest has an instance variable score: private int score…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 160

Multiple choice Writing Classes
Consider the following method from ClassX. private int modXY(int x, int y) { r = x / y; return x % y; } If ClassX compiles with no errors, which of the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 151 of 359
Page 16 of 36