
AP CSA Recursion (10.1)

Quiz
•
Computers
•
10th Grade
•
Medium
Herman Galioulline
Used 6+ times
FREE Resource
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);
Similar Resources on Wayground
10 questions
Python Input/Output

Quiz
•
9th - 12th Grade
10 questions
String Function Application in Python Quiz

Quiz
•
10th Grade
9 questions
Checkpoint 1 revision

Quiz
•
9th - 12th Grade
10 questions
Java Character and String class methods

Quiz
•
10th - 12th Grade
11 questions
Project STEM AP CS A Unit 1 Quiz Review

Quiz
•
9th - 12th Grade
10 questions
APCSA - Unit 3

Quiz
•
9th - 12th Grade
10 questions
Exam 2 MC

Quiz
•
10th - 12th Grade
10 questions
Java while loops

Quiz
•
10th - 12th Grade
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
Appointment Passes Review

Quiz
•
6th - 8th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
20 questions
Grammar Review

Quiz
•
6th - 9th Grade
Discover more resources for Computers
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
17 questions
[AP CSP] Binary Number System

Lesson
•
9th - 12th Grade
15 questions
1.1 Network Fundamentals Quiz

Quiz
•
10th Grade
20 questions
Understanding Information Processing Cycle

Quiz
•
10th Grade
19 questions
AP CSP Unit 1 Review (code.org)

Quiz
•
10th - 12th Grade