AP CSA Recursion (10.1)

AP CSA Recursion (10.1)

10th Grade

6 Qs

quiz-placeholder

Similar activities

Java String Methods Check

Java String Methods Check

10th - 12th Grade

6 Qs

C# Variables

C# Variables

10th Grade

10 Qs

7.7 Test Data Cambridge IGCSE 0478

7.7 Test Data Cambridge IGCSE 0478

10th Grade - University

10 Qs

String Review

String Review

10th - 12th Grade

5 Qs

SLR 9 - Advanced Programming Techniques - Part Two

SLR 9 - Advanced Programming Techniques - Part Two

10th Grade

10 Qs

AP CSP Python Quiz 1

AP CSP Python Quiz 1

10th - 12th Grade

11 Qs

Code.org Unit 7 Review

Code.org Unit 7 Review

9th - 12th Grade

8 Qs

Uji Kompetensi 2: Fungsi Spreadsheet

Uji Kompetensi 2: Fungsi Spreadsheet

10th Grade

10 Qs

AP CSA Recursion (10.1)

AP CSA Recursion (10.1)

Assessment

Quiz

Computers

10th Grade

Medium

Created by

Herman Galioulline

Used 6+ times

FREE Resource

6 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Media Image

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

Media Image

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

Media Image

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

Media Image

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

Media Image

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

Media Image

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);