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]
3 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]3 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
The process of converting information from a form/questionnaire is referred to as data preparation. This process follows a four-
Sergio [31]

Answer:

Data tabulation.

Explanation:

6 0
3 years ago
In 3–5 sentences, describe how good e-mail work habits increase workplace efficiency and productivity.
Ket [755]
Faster communication, information spread faster, group messages
6 0
3 years ago
The elements in a string type array will be initialized to ____.?
ivanzaharov [21]
The elements in a string type array will be initialized to "Null".
7 0
3 years ago
The letters LAN stand for Area Network.
Slav-nsk [51]

The letter LAN stand for : Local Area Network

8 0
2 years ago
Read 2 more answers
Which technology can be used as a defense against dos and ddos syn flood attacks?
Montano1993 [528]
In terms of websites, there's a service called cloud flare which can prevent DDOS attacks in websites. Other applications you would have to look up. Hopefully this helps!
6 0
3 years ago
Other questions:
  • What is the one common feature that ties together different social media technologies? All of the social media tools we use toda
    5·2 answers
  • There are many careers within the IT industry. _____ are responsible for organizing a company's data, making sure all the data i
    9·1 answer
  • The penalties for a person's third DUI conviction include fines of __________.
    11·2 answers
  • Some data files should be totally hidden from view, while others should have ____ so users can view, but not change, the data.
    11·1 answer
  • What is the difference between word processing software and email?
    12·2 answers
  • A media strategy that involves high ________ most likely involve creating broad exposure using many media vehicles, while a stra
    15·1 answer
  • Percentage-wise, which renewable energy source is used most?
    13·1 answer
  • . Write programming code in C++ for school-based grading system
    8·1 answer
  • PLEASE ANSWER THIS ASAP‼️
    10·2 answers
  • Simple interest will always pay more interest than compound interest.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!