Verityprep
Question Bank

AP® Computer Science A Multiple Choice Questions

Work through AP Computer Science A multiple-choice 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,631–2,640 of 2,811
  1. 2631
  2. 2632
  3. 2633
  4. 2634
  5. 2635
  6. 2636
  7. 2637
  8. 2638
  9. 2639
  10. 2640

Question 2631

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 2632

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 2633

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 2634

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 2635

Multiple choice Unit 4: Data Collections
A text file contains two lines:
hello world
goodbye
What is printed?
String s = sc.next();
String t = sc.nextLine();
sc.close();
System.out.println(s + t);
Pick an answer, then check it. The solution opens in a window.

Question 2636

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

Question 2637

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

Question 2638

Multiple choice Unit 4: Data Collections
A text file contains:    hello    world    (with extra spaces). What is printed?
String s = sc.next();
String t = sc.next();
sc.close();
System.out.println(s.length() + " " + t.length());
Pick an answer, then check it. The solution opens in a window.

Question 2639

Multiple choice Unit 4: Data Collections
A text file is completely empty (contains no data at all). What is printed?
boolean result = sc.hasNext();
sc.close();
System.out.println(result);
Pick an answer, then check it. The solution opens in a window.

Question 2640

Multiple choice Unit 4: Data Collections
A text file contains a single line: 5 (followed by a newline). What is printed? int n =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2,631 of 2,811
Page 264 of 282