Verityprep
Question Bank · Unit 4

AP® Computer Science A Data Collections Multiple Choice Questions

Work through AP Computer Science A multiple-choice questions on Data Collections, 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 901–910 of 1,079
  1. 901
  2. 902
  3. 903
  4. 904
  5. 905
  6. 906
  7. 907
  8. 908
  9. 909
  10. 910

Question 901

Multiple choice Using Text Files
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 902

Multiple choice Using Text Files
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 903

Multiple choice Using Text Files
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 904

Multiple choice Using Text Files
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 905

Multiple choice Using Text Files
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 906

Multiple choice Using Text Files
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 907

Multiple choice Using Text Files
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 908

Multiple choice Using Text Files
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 909

Multiple choice Using Text Files
A text file contains: 7. What is printed? String s…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 910

Multiple choice Using Text Files
A text file contains: 7. What is printed? String s =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 901 of 1,079
Page 91 of 108