answer.
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
adell [148]
2 years ago
6

How many times is the function wordScramble() called in the given program? public class WordScramble { public static void wordSc

ramble(String rem, String scr) { if (rem.isEmpty()) { System.out.println(scr + rem); } else { for (int i = 0; i < rem.length(); ++i) { wordScramble((rem.substring(0, i) + rem.substring(i + 1, rem.length())), (scr + rem.charAt(i))); } } } public static void main(String args[]) { wordScramble("ab", ""); } } 4 2 5 3
Computers and Technology
1 answer:
Ainat [17]2 years ago
6 0

Answer:

The answer is "2"

Explanation:

  • In the given java program code, a class WordScramble is declared, inside the class, a static method wordScramble is declared, that accepts two string parameter that is "rem and scr".
  • Inside the method a conditional statement is used in the if the block it checks rem variable value is empty so, it will add rem and scr value.  Otherwise, it will go to else block in this a loop is defined, which calls the method, which calculates rem length that is 2, and this method call two times to rearrange the values.
  • In the next step main method is defined that calls wordScramble method, which passes only one argument "ab" in its first parameter.
  • This method accepts one string value, in which there are two numbers   "a and b" that's why the method will run two times.  
You might be interested in
Use the image below to answer this question.
Leviafan [203]

Answer:

The question given is incomplete as it does not contains the image. I have found the image of the question and it is attached below.

The solution of the question is also attached below in the image.

I hope it will help you!

Explanation:

4 0
1 year ago
Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Follow each number by a space. Example
jasenka [17]

Answer:

public class Main

{

public static void main(String[] args) {

    int userNum = 40;

    while(userNum > 1){

        userNum /= 2;

        System.out.print(userNum + " ");

    }

}

}

Explanation:

*The code is in Java.

Initialize the userNum

Create a while loop that iterates while userNum is greater than 1. Inside the loop, divide the userNum by 2 and set it as userNum (same as typing userNum = userNum / 2;). Print the userNum

Basically, this loop will iterate until userNum becomes 1. It will keep dividing the userNum by 2 and print this value.

For the values that are smaller than 1 or even for 1, the program outputs nothing (Since the value is not greater than 1, the loop will not be executed).

4 0
2 years ago
Assume that the reference variable r refers to a serializable object. Write code that serializes the object to the file ObjectDa
laiz [17]

Answer:

FileOutputStream out = new FileOutputStream("ObjectData.dat");

ObjectOutputStream ostream = new ObjectOutputStream(out);

ostream.writeObject(r);

Explanation:

For object serialization, we can use the writeObject method of java.io.ObjectOutputStream class.

The complete code fragment is as follows:

import java.io.*;

class Demo{

      public static void main(String args[]){

             try{

                  r = <Reference to Object to be serialized> ;

                 FileOutputStream out = new FileOutputStream("ObjectData.dat");

                 ObjectOutputStream ostream = new ObjectOutputStream(out);

                  ostream.writeObject(r);

                 ostream.close();

            } catch(Exception e){

                   e.printStackTrace();

            }

      }

}

5 0
1 year ago
In three to five sentences, explain how you would insert graphics using your word-processing software.
madam [21]
Most word-processing programs allow the user to select a command from the menu to insert a graphic. Clicks in the document where you want your file, choose insert and picture click from file select the image the press open and you picture will become inserted in to the document.
3 0
2 years ago
Read 2 more answers
Mechanical advantage is the ratio of the force required to move a load divided by______
Veseljchak [2.6K]
I am not sure but i think it is 2 or 4 because a pc can withstand the power of volts, drive, ram, and data
3 0
2 years ago
Other questions:
  • Computer design software requires __________________ to be used properly and successfully by architects.
    9·2 answers
  • Any software or program that comes in many forms and is designed to disrupt the normal operation of a computer by allowing an un
    13·1 answer
  • _____________ involves the deployment of malware that secretly steals data in the computer systems of organizations, such as gov
    13·1 answer
  • You are researching RAM for a computer you are building for a friend who will be using the system as a home office server for he
    14·1 answer
  • Raj needs to apply sorting to a current list in his Word document.
    11·2 answers
  • Susie works for an architectural firm and the partners have always drawn the plans for projects by hand. Though Susie learned ho
    11·1 answer
  • Given a sorted array of integer, A, with possible duplicate elements. Implement an efficient (sublinear running time complexity)
    12·1 answer
  • Write a fragment of code that reads in strings from standard input, until end-of-file and prints to standard output the largest
    10·1 answer
  • Print "userNum1 is negative." if userNum1 is less than O. End with newline Convert userNum2 to 0 if userNum2 is greater than 8.
    10·1 answer
  • Question 1 :Which type of unshielded twisted pair (UTP) cable is commonly used for 1000BASE-T Ethernet networks and is often mad
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!