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
Angelina_Jolie [31]
4 years ago
7

Assume that x and y are integer variables that have been initialized to 20 and 10, respectively. What is the output of the follo

wing code segment? System.out.println( x + "\t" + y ); swap( x, y ); System.out.println( x + "\t" + y ); public static void swap( int a, int b ) { if( a > b ) { int temp = b; b = a; a = temp; } System.out.println( a + "\t" + b ); }
Computers and Technology
1 answer:
ad-work [718]4 years ago
8 0

Answer:

// here is the complete code in java to check the output.

import java.util.*;

class Main

{

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

{

   try{

       int x=20,y=10;

       System.out.println( x + "\t" + y );

       swap( x, y );

       System.out.println( x + "\t" + y );

   }catch(Exception ex){

       return;}

}

public static void swap( int a, int b )

{

    if( a > b )

    {

        int temp = b;

        b = a;

        a = temp;

        }

        System.out.println( a + "\t" + b );    

}

}

Explanation:

Here is "x" is initialize with 20 and "y" is with 10. The first print statement  will print the value of "x" and "y"  separated by a tab. Then it will the swap() method with parameter x and y.In the swap method, if first parameter is greater then it will swap the two value and the print statement will execute. It will print 10 and 20 separated by a tab. then in the main method, print statement execute And print the value of x,y as 20 and 10. Here value of x, y will not change by the method swap() because in java parameters are passed by value not by reference.That is why  any change by swap() method will not reflect in the main method.

Output:

20      10                                                                                                                                                    

10      20                                                                                                                                                    

20      10

You might be interested in
Your job is to write a basic blurring algorithm for a video driver. The algorithm will do the following: it will go through all
nekit [7.7K]
I’m pretty sure answer is B let me know if I’m wrong
4 0
4 years ago
In cell B20, enter a
zzz [600]

Answer:

かあなたは棚田やヌタほたややあはあやあやあさあ与田弥太は沙汰やあはあわあね、田やホワアラハやくださいヤアカやさ矢田かほあや体は白湯のやさた

Explanation:

なたさたらなやさゆなやさら

5 0
2 years ago
_______ computing refers to applications and services that run on a distributed network using virtualized resources.
denis23 [38]
D.cloud is my answer
7 0
4 years ago
What are the similarities and differences between the sample résumés, in terms of content and formatting?
poizon [28]

Answer:

in general terms a sample resume would have less on it with more of a general overview,while a full resume has the whole 9 yards  

6 0
4 years ago
In object-oriented programming, what is a constructor?
hjlf

A constructor in object-oriented programming is a special method of a class or structure that initializes an object of that type. Basically, it resembles an instance method that usually has the same name as the class. In simple terms, it is a subroutine called to create an object.






3 0
4 years ago
Other questions:
  • How do you mark somebody the brainliest?
    14·2 answers
  • Max Weber's concept of ________ implies that, in conducting research, social scientists must try to understand others' view of r
    14·2 answers
  • 1. _____ can’t be rewritten by the computer in which it’s installed, but it has the advantage of being very _____.
    6·1 answer
  • Now, Kim wants to add the technical terms she typically misspells to the PowerPoint built-in list. Which option should she use t
    15·2 answers
  • _____ enable patients to use the Internet to compare the quality, safety, and cost information on hospitals nationwide.
    6·1 answer
  • If you want to distribute a formatted Microsoft word document to people who don't have word save it as a __file
    5·1 answer
  • A(n) ________ CPU has two processing paths, allowing it to process more than one instruction at a time. Group of answer choices
    5·1 answer
  • Using complete sentences post a detailed response to the following.
    15·1 answer
  • Which sentence describes a biotechnology method of treating sulfur liquor in the paper industry?
    11·1 answer
  • ________ is a technique where the general characteristics are kept and the details are hidden.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!