1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Bumek [7]
4 years ago
10

Consider the recursive method whose definition appear below. Why? public static String mysteryString (String s){ if(s.length()==

1) return s; else return s.substring(s.length() – 1) + mysteryString(s.substring(0, s.length() – 1)); } What is the result of the following call?
System.out.println(mysteryString("computer"));
Computers and Technology
1 answer:
Marizza181 [45]4 years ago
6 0

Answer:

retupmoc

Explanation:

1.) Anwser will be retupmoc

because

public static String mysteryString(String s){

if(s.length() == 1){

return s;

}

else{

return s.substring(s.length() -1) + mysteryString(s.substring(0, s.length()-1));

}

}

In this program input is "computer" . So the function mysteryString(String s) it does

return s.substring(s.length() -1) + mysteryString(s.substring(0, s.length()-1));

so when it enters the first time ??s.substring(s.length() -1) and it will be give you 'r' then it calls the function recursively by reducing the string length by one . So next time it calls the mysteryString function with string "compute" and next time it calls return s.substring(s.length()-1)? + mysteryString(s.substring(0,s.length-1)) so this time it gives "e" and calls the function again recursively . It keeps on doing till it matched the base case.

so it returns "retupmoc".

You might be interested in
A(n) ___________________ process is initiated by individuals who are subjected to forensic techniques with the intention of hidi
dlinn [17]
A(n) anti-forensics process is initiated by individuals who are subjected to forensic techniques with the intention of hiding or obfuscating items or objects with evidentiary value.
4 0
3 years ago
The mouse and keyboard are also sometimes called
likoan [24]
Hi!

The mouse and the keyboard are <em>input devices. </em>By using them, we can input data which will give us a (hopefully) desired output!

For example...

Just by using my keyboard to type, I'm inputting data in the form of ASCII characters and symbols.

By using my mouse to click on an area so I can move this sentence on a new line, I had to input a request to do such!

Hopefully, this helps! =)
7 0
4 years ago
Which is the best software application to be used by a hotel manager​
cluponka [151]

Answer:

Cloudbeds

:))

hope it helps

5 0
3 years ago
Which would be the best reason to consider using plain tables instead of shaded tables in a document?
Eva8 [605]
The best reason to consider using plain tables instead of shaded tables in a document if the document will be copied frequently. The shaded table will  be copied exactly as shaded, and time will be wasted unshading (converting shaded table to plain table) them.  
3 0
4 years ago
Read 2 more answers
Using a Mouse
MariettaO [177]
I think it might be A. mouse sorry if I get it wrong tho hope it’s right.
7 0
3 years ago
Read 2 more answers
Other questions:
  • Which one of the following analog VOM ranges would be selected to measure a DC current of 90 milliamps? A. 10mA B. 1.0A C. 10A D
    14·2 answers
  • Which of the following is where you can save, select a template, change document properties, and close or exit excel?
    8·1 answer
  • Is it okay to leave your car running while parked?
    15·1 answer
  • A growing number of large organizations have built internal Web sites that provide opportunities for online social networking am
    7·1 answer
  • Write a code block to encode strings from original messages, using our custom encoding. To do so: Initialize a variable called c
    6·1 answer
  • While accessing mail through the mail command interface, a user sees 5 new messages in his mailbox. Since the second message app
    13·1 answer
  • PLEASE HELP ME ASAP!!! THIS IS DUE SOON!!
    9·1 answer
  • Spreadsheet software can be used to do all the following except _____.
    5·2 answers
  • What happens when i expose a disk to magnetic fields?​
    5·1 answer
  • The project team is creating detailed documents to guide the team. What phase of the project life cycle are they in?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!