Verityprep
Question Bank

AP® Computer Science A Practice Questions

Work through AP Computer Science A practice questions unit by unit, 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.

Questions 2,911–2,920 of 3,140
  1. 2911
  2. 2912
  3. 2913
  4. 2914
  5. 2915
  6. 2916
  7. 2917
  8. 2918
  9. 2919
  10. 2920

Question 2911

Free response Unit 4: Data Collections
This question involves the design of a class that maintains a collection of books on a library shelf. The following Book class is provided. public class Book {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2912

Free response Unit 4: Data Collections
Consider a class MessageGrid that stores words in a two-dimensional array. The 2D array grid may contain null rows, and a non-null row may contain null…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2913

Free response Unit 4: Data Collections
You will write the NumberGrid class, which stores integers in a two-dimensional array. The declaration of the NumberGrid class is shown below. You may assume…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2914

Free response Unit 4: Data Collections
You will write the WordGrid class, which stores words in a two-dimensional array. The declaration of the WordGrid class is shown below. You may assume that grid…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2915

Multiple choice Unit 4: Data Collections
A text file contains a single line: 42. What is printed by the following code? Assume sc is a properly constructed Scanner reading that file.
int x = sc.nextInt();
sc.close();
System.out.println(x + 8);
Pick an answer, then check it. The solution opens in a window.

Question 2916

Multiple choice Unit 4: Data Collections
A text file contains a single line: Hello World. What is printed?
String s = sc.nextLine();
sc.close();
System.out.println(s.length());
Pick an answer, then check it. The solution opens in a window.

Question 2917

Multiple choice Unit 4: Data Collections
A text file contains: apple banana cherry. What is printed?
String s = sc.next();
sc.close();
System.out.println(s);
Pick an answer, then check it. The solution opens in a window.

Question 2918

Multiple choice Unit 4: Data Collections
A text file contains: 3.5. What is printed?
double d = sc.nextDouble();
sc.close();
System.out.println(d * 2 + 1);
Pick an answer, then check it. The solution opens in a window.

Question 2919

Multiple choice Unit 4: Data Collections
A text file contains: true. What is printed?
boolean b = sc.nextBoolean();
sc.close();
if (b) {
    System.out.println("YES");
} else {
    System.out.println("NO");
}
Pick an answer, then check it. The solution opens in a window.

Question 2920

Multiple choice Unit 4: Data Collections
A text file contains: 7 3. What is printed?
int a = sc.nextInt();
int b = sc.nextInt();
sc.close();
System.out.println(a / b);
Pick an answer, then check it. The solution opens in a window.
Question 2,911 of 3,140
Page 292 of 314