
AP CSA Recursion (10.1)
Authored by Herman Galioulline
Computers
10th Grade
Used 6+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
6 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Which of the following best describes the output produced by the method call mystery(val)?
All integers from 1 to val, separated by spaces
All integers from val to 1, separated by spaces
The digits of val in their original order, separated by spaces
The digits of val in reverse order, separated by spaces
The last digit of val, then a space, then the first digit of val
2.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following method, which is intended to return the sum of all the even digits in its parameter num. For example, sumEvens(15555234) should return 6, the sum of 2 and 4.
Which of the following can be used as a replacement for /* missing statement */ so that the sumEvens method works as intended?
return sumEvens(num % 10);
return sumEvens(num / 10);
return num % 10 + sumEvens(num % 10);
return num % 10 + sumEvens(num / 10);
return num / 10 + sumEvens(num % 10);
3.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Which of the following best describes the result of the call doSomething(myString)?
The method call returns a String containing the contents of myString unchanged.
The method call returns a String containing the contents of myString with the order of the characters reversed from their order in myString.
The method call returns a String containing all but the first character of myString.
The method call returns a String containing only the first and second characters of myString.
The method call returns a String containing only the first and last characters of myString.
4.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Which of the following best describes the value returned by the method call calc(num)?
The int value 9
The leftmost digit of num
The rightmost digit of num
The number of digits in num
The result of the integer division of num by 10
5.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following recursive method, which is intended to return a String with any consecutive duplicate characters removed. For example, removeDupChars("aabcccd") returns "abcd".
Which of the following can replace /* missing code */ so that removeDupChars works as intended?
return removeDupChars(str.substring(2));
return removeDupChars(str.substring(1)) + str.substring(0, 1);
return removeDupChars(str.substring(2)) + str.substring(1, 2);
return str.substring(0, 1) + removeDupChars(str.substring(1));
return str.substring(1, 2) + removeDupChars(str.substring(2));
6.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following recursive method, which is intended to display the binary equivalent of a decimal number. For example, toBinary(100) should display 1100100.
Which of the following can replace /* missing code */ so that toBinary works as intended?
System.out.print(num % 2);
toBinary(num / 2);
System.out.print(num / 2);
toBinary(num % 2);
toBinary(num % 2);
System.out.print(num / 2);
toBinary(num / 2);
System.out.print(num % 2);
toBinary(num / 2);
System.out.print(num / 2);
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
10 questions
Diplo Variables
Quiz
•
1st - 10th Grade
10 questions
TIK Kelas X
Quiz
•
10th Grade
10 questions
Programming Constructs_Y10
Quiz
•
9th - 12th Grade
10 questions
Algoritmos 01
Quiz
•
10th Grade
11 questions
Trabajando con ArrayList
Quiz
•
9th - 12th Grade
11 questions
CIW IBA Lesson 4 Vocabulary
Quiz
•
8th Grade - Professio...
10 questions
XI 1 Ulangan Harian 1 INFORMATIKA Bahasa C
Quiz
•
10th Grade
10 questions
QBASIC Programming
Quiz
•
5th - 10th Grade
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade