Part-1: Study the following method, then perform the required steps and answer the questions below: public static void swap(int numl, int num2){ System.out.println("Inside the swap method:"); System.out.println("Before swapping, numl is int temp = пит1 %3 пит2; пит2 3D temр; System.out.println("After swapping, numl is + пиml + and num2 is + пит2); %3D пит1; + пиml + and num2 is + num2); %3D %3D a. Copy this method in your main class. b. In your main method, declare and initialize two integers. Choose variables names other than num1 and num2. Then, invoke the swap method and pass your integers as arguments. Print the values of your integers before and after the invocation of the swap method. Do the values of your integers change after invoking the swap method? Why? c. Now declare your integers with the names num1 and num2. Is it allowable for parameters and arguments to have same names? Why? If your answer is yes, do the values of your integers change after invoking the swap method in this case?

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

java ..... please solve the questions

P1r AITAY
Object-Oriented !
Part-1: Study the following method, then perform the required steps and answer the
questions below:
public static void swap(int numl, int num2){
System.out.println("Inside the swap method:");
System.out.println("Before swapping, num1 is "+ num1 + " and num2 is
int temp 3 nит1;
пит1 — пит2;
num2 = temp;
+ пит2);
System.out.println("After swapping, num1 is " + num1 + " and num2 is " + num2);
a. Copy this method in your main class.
b. In your main method, declare and initialize two integers. Choose variables names
other than numl and num2. Then, invoke the swap method and pass your integers as
arguments. Print the values of your integers before and after the invocation of the
swap
method. Do the values of your integers change after invoking the swap method?
Why?
c. Now declare your integers with the names num1 and num2. Is it allowable for
parameters and arguments to have same names? Why? If your answer is yes, do the
values of your integers change after invoking the swap method in this case?
Transcribed Image Text:P1r AITAY Object-Oriented ! Part-1: Study the following method, then perform the required steps and answer the questions below: public static void swap(int numl, int num2){ System.out.println("Inside the swap method:"); System.out.println("Before swapping, num1 is "+ num1 + " and num2 is int temp 3 nит1; пит1 — пит2; num2 = temp; + пит2); System.out.println("After swapping, num1 is " + num1 + " and num2 is " + num2); a. Copy this method in your main class. b. In your main method, declare and initialize two integers. Choose variables names other than numl and num2. Then, invoke the swap method and pass your integers as arguments. Print the values of your integers before and after the invocation of the swap method. Do the values of your integers change after invoking the swap method? Why? c. Now declare your integers with the names num1 and num2. Is it allowable for parameters and arguments to have same names? Why? If your answer is yes, do the values of your integers change after invoking the swap method in this case?
Expert Solution
steps

Step by step

Solved in 5 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY