Solved

What Does the Following Method Compute? Assume the Method Is

Question 12

Multiple Choice

What does the following method compute? Assume the method is called initially with i = 0
Public int question9(String a, char b, int i)
{
If (i = = a.length( ) ) return 0;
Else if (b = = a.charAt(i) ) return question9(a, b, i+1) + 1;
Else return question9(a, b, i+1) ;
}


A) the length of String a
B) the length of String a concatenated with char b
C) the number of times char b appears in String a
D) returns 1 if char b appears in String a at least once, and 0 otherwise
E) the char which appears at location i in String a

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents