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
aleksley [76]
3 years ago
11

Consider the following recursive method, which is intended to return a String with any consecutive duplicate characters removed.

For example, removeDupChars("aabcccd") returns "abcd".public static String removeDupChars(String str){if (str == null || str.length() <= 1){return str;}else if (str.substring(0, 1).equals(str.substring(1, 2))){return removeDupChars(str.substring(1));}else{/* missing code */}}Which of the following can replace /* missing code */ so that removeDupChars works as intended?A. return removeDupChars(str.substring(2));B. return removeDupChars(str.substring(1)) + str.substring(0, 1);C. return removeDupChars(str.substring(2)) + str.substring(1, 2);D. return str.substring(0, 1) + removeDupChars(str.substring(1));E. return str.substring(1, 2) + removeDupChars(str.substring(2));
Computers and Technology
1 answer:
saul85 [17]3 years ago
4 0

Answer:

D. return str.substring(0, 1) + removeDupChars(str.substring(1));

Explanation:

The logic here is following:

If the there are consecutive duplicate characters, return the removeDupChars method. The parameter of the removeDupChars method is a string, but the duplicate of the first character is removed from the string. The else-if part of the program does this job.

If the consecutive characters are not duplicated, return the first character of the string and the removeDupChars method. The parameter of the removeDupChars method is the rest of the string characters. The else part of the program does this job.

When the length of the str becomes one (or when the str is null), the program reaches its base and returns the str. The if part of the program does this job.

You might be interested in
Hanging out with friends, watching your favorite TV show, and buying a pair of new shoes are all examples of _____ for doing wel
SpyIntel [72]
<span>Hanging out with friends, watching your favorite TV show, and buying a pair of new shoes are all examples of rewards for doing well in school. As the result of doing well in studies, a person can hang out with friends, watch their own favorite TV show and can buy a new pair of shoes. Hence all these things are the rewards that are being generated for a good performance in school.</span>
8 0
3 years ago
Read 2 more answers
Which of the following criteria would not make a person eligible to receive medicare benefits?Which of the following criteria wo
Mumz [18]
B terminal illness .....
4 0
3 years ago
Read 2 more answers
PYTHON:Given the dictionary, d, find the largest key in the dictionary and associate the corresponding value with the variable v
lapo4ka [179]

di = {5: 3, 4: 1, 12: 2}

val_of_max = di[max(di)]

print(val_of_max)

I hope this helps!

4 0
3 years ago
What are the seven internal compontents of a computer
likoan [24]
Motherboard, CPU, fans, Hard drives,Power Supply,Optical Drives and RAM
4 0
3 years ago
Weber believed that there is an inevitable destructive quality to which one of the four types of action?
weqwewe [10]

Answer:

instrumental-rational                                        

Explanation:

  • A sociologist Max Weber interpreted the effects of Industrial Revolution on social actions. He described the four types of social actions:

                     Traditional Social Action

                      Affective/Affectional Social Action

                     Value Rational Social Action

                  Instrumental-Rational  Social Action

  • Instrumental-rational means to pursue most efficient means to achieve a specific goal.
  • The goals of the actions are also used as a way of achieving certain objectives.
  • So instrumental rational means doing anything it takes to reach a certain goal that does not take into account the consequences of the actions taken to achieve this goal.  
  • For example an organization's goal is to make maximize profit so it will use most effective and economical means to achieve this goal. For example by decreasing workers not considering the affects on the workers of this action.
  • Another example is of a person who wants to gain money. He might rob others or sell drugs etc to get money. A student whose goal is to pass an exam in order to get a degree will give his time to study and might cheat in exam to pass the test.
  • In short any actions can be taken which leads to the achievement of  a certain goal.
  • According to Weber instrumental rationality is destructive because rather than pursuing means and making decisions by taking moral values into consideration, the basic focus is to achieve a goal and make decisions using efficiency not considering moral values.
8 0
3 years ago
Other questions:
  • Java - Given a String variable response that has already been declared, write some code that repeatedly reads a value from stand
    12·1 answer
  • My home PC has IP address 192.168.1.22 and connects to the Internet through a NAT router. Assume I am downloading a web page fro
    5·1 answer
  • a corporation needs an operating system that allows the various teams in its office to network &amp; collaborate on projects. wh
    11·2 answers
  • Given numRows and numColumns, print a list of all seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E. Print
    14·1 answer
  • python Write a program that will take a file named Celsius.dat that contains a list of temperatures in Celsius (one per line), a
    9·1 answer
  • To build a user interface that contains graphical components, the components ____. must each be added to a separate panel. must
    7·1 answer
  • True or false questions:
    11·1 answer
  • Which of the following operation is not performed by a mouse 1) left click , middle click , right click, double click​
    15·2 answers
  • The Last Free brainliest<br><br> This Is The Last Brainliest That Im Doing Forever Sorry Guys
    8·2 answers
  • swer from the options 1. How many basic input devices does a desktop computer have? a)2 b)3 c)1 d)4 2. The computer equipment wh
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!