Verityprep
Question Bank · Unit 3

AP® Computer Science A Class Creation Practice Questions

Work through AP Computer Science A practice 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 161–170 of 402
  1. 161
  2. 162
  3. 163
  4. 164
  5. 165
  6. 166
  7. 167
  8. 168
  9. 169
  10. 170

Question 161

Multiple choice Writing Classes
A certain class, SomeClass, contains a method with the following header. public int getValue(int n) Suppose that methods with the following headers are now…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 162

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 163

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 164

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 165

Free response Writing Classes
This question involves keeping track of details for a world cruise, using a Cruise class. A Cruise object is created with two parameters, the number of people…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 166

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 167

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 168

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 169

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 170

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 161 of 402
Page 17 of 41