Question 991
Multiple choice
Sorting And Searching
Work through AP Computer Science A practice 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.
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);
Hello World. What is printed?
String s = sc.nextLine();
sc.close();
System.out.println(s.length());
apple banana cherry. What is printed?
String s = sc.next();
sc.close();
System.out.println(s);
3.5. What is printed?
double d = sc.nextDouble();
sc.close();
System.out.println(d * 2 + 1);
AP® and Advanced Placement® are registered trademarks of the College Board, which is not affiliated with, and does not endorse, Verityprep. Names are used for identification purposes only.