7. Functions and arrays. Consider the following three Java functions. public static int halvel (int x) { x = x / 2; return x; } public static void halve2 (int[] a) { int n = a.length; for (int i = 0; i

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter2: Using Data
Section: Chapter Questions
Problem 14RQ
icon
Related questions
Question

Question Kk ( A)  

Full explain this question very fast solution sent me step by step

7. Functions and arrays.
Consider the following three Java functions.
public static int halvel (int x) {
x = x / 2;
return x;
}
public static void halve2 (int[] a) {
int n = a.length;
}
for (int i = 0; i < n; i++) {
halvel (a[i]);
a[i] = halvel (a[i]);
}
}
public static void halve3 (int[] a) {
int na.length;
int[] b = new int [n/2];
for (int i = 0; i < n/2; i++)
b[i] = a[i];
a = b;
I
(a) What are the contents of the array a [] after executing the following three lines of code?
Write your answer in the box below.
int[] a = { 16, 32, 48, 64 };
halve2 (a);
halve2 (a);
Transcribed Image Text:7. Functions and arrays. Consider the following three Java functions. public static int halvel (int x) { x = x / 2; return x; } public static void halve2 (int[] a) { int n = a.length; } for (int i = 0; i < n; i++) { halvel (a[i]); a[i] = halvel (a[i]); } } public static void halve3 (int[] a) { int na.length; int[] b = new int [n/2]; for (int i = 0; i < n/2; i++) b[i] = a[i]; a = b; I (a) What are the contents of the array a [] after executing the following three lines of code? Write your answer in the box below. int[] a = { 16, 32, 48, 64 }; halve2 (a); halve2 (a);
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

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
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT