When the base case is met, which of these could be returned?
[Enclosing method: recursiveFunc(int n)]
Recursion in Java (AP Computer Science A)
Quiz
•
Computers
•
9th - 12th Grade
•
Medium
Patrick Ferrer
Used 99+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
When the base case is met, which of these could be returned?
[Enclosing method: recursiveFunc(int n)]
return recursiveFunc(n + 1);
return (double) 1000;
return n * recursiveFunc(n);
return recursiveFunc(n) - 1;
2.
MULTIPLE CHOICE QUESTION
20 sec • 1 pt
The capabilities of a recursive function can typically be recreated by . . .
If / Else statements
Classes
Loops
Interfaces
3.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
For which of these operations is a recursive function practical?
Scanning user input
Finding the sum of two integers
Returning the first item of a list
Calculating the factorial of an integer
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is a recursive function?
Function that returns once
Function that creates objects
Function that calls itself
Function needing abstraction to be used
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of these is NOT an acceptable header for a recursive function?
public void recursiveFunc(Object obj) {
public int recursiveFunc(int n) {
public double recursiveFunc(double n) {
public String recursiveFunc(String str) {
6.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
Assuming n is initialized as an integer variable with a positive value, what will be printed?
The factorial of n
The absolute value of n
The sum of all digits in n
The square root of n
7.
MULTIPLE SELECT QUESTION
2 mins • 1 pt
The Collatz Conjecture states that, in sequence, taking any integer and, if even, halving the result/integer and, if odd, tripling and adding 1 to the result/integer continuously will eventually end up as 1.
Which of the above methods properly recreates the conjecture?
Select all answers that apply.
(Click the picture to enlarge.)
recursiveCollatz1(int n)
recursiveCollatz2(int n)
recursiveCollatz(int n)
None
12 questions
3.TR - PHP 11
Quiz
•
11th Grade
10 questions
PCEP Section 4B: the function and its environment
Quiz
•
12th Grade
10 questions
Evaluasi PHP 4
Quiz
•
10th Grade
15 questions
Тест з програмування на Python
Quiz
•
12th Grade - University
7 questions
Arrays 2022/02/15
Quiz
•
10th Grade
10 questions
GDScript Quiz - Lesson 2 - Variables & Functions
Quiz
•
12th Grade
11 questions
Python function output based KVRDSO lucknow
Quiz
•
11th - 12th Grade
12 questions
Python_4
Quiz
•
9th - 12th Grade
15 questions
Multiplication Facts
Quiz
•
4th Grade
20 questions
Math Review - Grade 6
Quiz
•
6th Grade
20 questions
math review
Quiz
•
4th Grade
5 questions
capitalization in sentences
Quiz
•
5th - 8th Grade
10 questions
Juneteenth History and Significance
Interactive video
•
5th - 8th Grade
15 questions
Adding and Subtracting Fractions
Quiz
•
5th Grade
10 questions
R2H Day One Internship Expectation Review Guidelines
Quiz
•
Professional Development
12 questions
Dividing Fractions
Quiz
•
6th Grade
25 questions
Spanish preterite verbs (irregular/changed)
Quiz
•
9th - 10th Grade
10 questions
Identify Slope and y-intercept (from equation)
Quiz
•
8th - 9th Grade
10 questions
Juneteenth: History and Significance
Interactive video
•
7th - 12th Grade
8 questions
"Keeping the City of Venice Afloat" - STAAR Bootcamp, Day 1
Quiz
•
9th - 12th Grade
26 questions
June 19th
Quiz
•
4th - 9th Grade
20 questions
Distance, Midpoint, and Slope
Quiz
•
10th Grade
20 questions
Figurative Language Review
Quiz
•
10th Grade
27 questions
STAAR English 1 Review
Quiz
•
9th Grade