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
Sloan [31]
3 years ago
14

There are two String variables, s1 and s2, that have already been declared and initialized. Write some code that exchanges their

values. Declare any other variables as necessary.
Computers and Technology
2 answers:
Ivan3 years ago
8 0

Answer:

//here is code in java.

import java.util.*;

class Solution

{

// main method of class

public static void main (String[] args) throws java.lang.Exception

{

   try{

    // declare an initialize first string variables

     String st1="hello";

     // declare an initialize first string variables

     String st2="world";

     // create another string variable

    String st3;

    // exchange the value of both string variables

    st3=st1;

    st1=st2;

    st2=st3;

    System.out.println("value of first String after exchange: "+st1);

    System.out.println("value of second String after exchange: "+st2);

   }catch(Exception ex){

       return;}

}

}

Explanation:

declare and initialize two string variables.Create another string variable "st3". first assign value of "st1" to "st3" after then value of "st2" to "st1" and then  assign value of "st3" to "st2". This will exchange the values of both the string.

Output:

value of first String after exchange: world

value of second String after exchange: hello

Lunna [17]3 years ago
5 0

Answer:

The following are the code

string s1="san";

string s2="ran";

string temp; // other variable

temp=s1;// statement 1

s1=s2;// statement 2

s2=temp;//statement 3

Explanation:

In this code we declared two string s1 , s2 and initialized them after that we declared an extra variable temp .

The statement 1  temp=s1   means that temp will store the value of s1 i.e "san". so temp="san";

The second statement 2  s1=s2   means that s1 will store the value of s2

i.e s1="ran";

The third statement 3 s2=temp means that s2 will store the value of temp.

i.e s2="san"

we see that s1 and s2 will exchange their value

Following are the code in c++

#include <iostream> // header file

#include<string>

using namespace std;

int main()// main function

{

string s1="san";

string s2="ran";

string temp;

cout<<"before exchange:"<<s1<<s2<<endl; // display before exchanging the value

temp=s1;

s1=s2;

s2=temp;

cout<<"after exchange:"<<s1<<s2<<endl;// display after exchanging the value

return 0;

}

Output:

before exchange:sanran

after exchange:ransan

You might be interested in
Which of the following terms best describes the security domain that relates to how data is classified and valued?
d1i1m1o1n [39]

Answer:

c) Access Control.

Explanation:

The term which describes the security domain best that relates to  how the data is valued and classified is Access Control.

Access Control :It is the restriction of access of a resource or a place that is selective.Permission to access a resource is called authorization.It is an important term in the field of information security and physical security.

7 0
3 years ago
The ____ is a tool in versions of microsoft office starting with office 2007 that consists of tabs, which contain groups of rela
tankabanditka [31]

The answer is A. The Ribbon is a UI component which was presented by Microsoft in Microsoft Office 2007. It is situated underneath the Quick Access Toolbar and the Title Bar. It includes seven tabs; Home, Insert, Page design, References, Mailing, Review and View. Every tab has particular gatherings of related summons.

6 0
3 years ago
The protocol that enables computers on the Internet to communicate with each other is called _____.
dybincka [34]
"C" is the correct answer, if its correct please mark me brainliest.
5 0
3 years ago
You are the administrator for a network with a single Active Directory domain called westsim. All computer accounts reside in or
N76 [4]
Link a GPO to the Marketing OU. In the GPO, edit the Enable client-side targeting policy and specify the Marketing Computers group.

In the WSUS console, edit the options for Computers and specify Use Group Policy or registry settings on computers.

In the WSUS console, create a Marketing Computers group.
3 0
2 years ago
Which function prompts the user to enter information?
Rzqust [24]

Answer:

input() prompts the user to enter information

6 0
3 years ago
Read 2 more answers
Other questions:
  • helppppp asap!!!!!!!!!! Sara has just started using the Internet. She would like to be a little more efficient. In 3–4 sentences
    9·2 answers
  • 1) why is software engineering considered engineering and not manufacturing?
    9·1 answer
  • How do you design video games
    5·1 answer
  • Explain the third <br> generation
    6·1 answer
  • List and describe the tools for all the main stages of app/application development.
    11·1 answer
  • Suppose you are given a data set consisting of nominal attributes, such as color, which takes values such as red, blue, green et
    9·1 answer
  • Explain mechanical computer ,electromechanical and electronic computer with example<br>​
    11·1 answer
  • Which of these is a negative effect of computer technology's role in creating
    9·1 answer
  • How to edit slides into video.
    13·1 answer
  • If I want to make it look like slide number one is turning a page to slide number two, what
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!