fill in the table to trace the values as they are passed from main and changed in the method.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

For each part below, fill in the table to trace the values as they are passed from main and changed in the method.

a.

int [] array = {1,2,3,4,5};

int x = 12;

int y = doOne(array,x);

 

 

int [ ] array2 = {1,2,3,4,5};

int w = doOne(array2, array2[3]);

 

} // end of main

 

public static int doOne(int[] arr, int x){

for (int i=0; i<arr.length-1; i++)

arr[i] = arr[i]*arr[i+1];

x = x+3;

return x;

}

 

 

x in main before call to doOne

 

 

array in main before call to doOne

 

 

arr in doOne before loop

 

 

x in doOne before loop

 

 

arr in doOne after loop

 

 

x in doOne after loop

 

 

x in main after call to doOne

 

 

y in main after call to doOne

 

 

array in main after call to doOne

 

 

 

 

array2 in main before call to doOne

 

 

arr in doOne before loop

 

 

x in doOne before loop

 

 

arr in doOne after loop

 

 

x in doOne after loop

 

 

w in main after call to doOne

 

 

array2 in main after call to doOne

 

 

b.

int [] array3 = {1,2,3,4,5};

int s = 12;

int v = 32;

int [] num = doTwo(array3, v,s);

 

} // end of main

 

public static int[] doTwo(int[] arr, int x, int y){

int[] ret = new int[2];

x = arr[2] ;

y = arr[3] ;

ret[0] = x+arr[1];

ret[1] = y-arr[0];

return ret;

}

 

 

array3 before call to doTwo

 

 

s before call to doTwo

 

 

v before call to doTwo

 

 

arr in doTwo

 

 

x in doTwo

 

 

y in doTwo

 

 

ret in doTwo

 

 

array3 in main after call to doTwo

 

 

num in main after call to doTwo

 

 

s in main after call to doTwo

 

 

v in main after call to doTwo:

 

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education