Consider the following three Java functions. public static int halvel (int x) { x = x...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Consider the following three Java functions. public static int halvel (int x) { x = x / 2; return x; } public static void halve 2 (int[] a) ( int na.length; for (int i=0; i < n; i++) { halvel (a[i]); a[i] halvei (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; } (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); (b) 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 }; halve3(a); halve3(a); Consider the following three Java functions. public static int halvel (int x) { x = x / 2; return x; } public static void halve 2 (int[] a) ( int na.length; for (int i=0; i < n; i++) { halvel (a[i]); a[i] halvei (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; } (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); (b) 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 }; halve3(a); halve3(a);
Expert Answer:
Related Book For
Engineering Economic Analysis
ISBN: 9780195168075
9th Edition
Authors: Donald Newnan, Ted Eschanbach, Jerome Lavelle
Posted Date:
Students also viewed these databases questions
-
s1 educated (SSE) student for every three public school educated (PSE) students. Reasoning that students are not very dissimilar from threads, he suggests the following entry and exit routines be...
-
Developments in Technology Light is incident from air on the end face of a multimode optical fibre at angle of incidence as shown below. n n 1 2 The refractive indices of the core and cladding are...
-
The Jasper SkyTram transports passengers to the top of Whistler Mountain in the Canadian Rockies where there are spectacular views, boardwalks, and hiking trails. The SkyTram travel time (in minutes)...
-
Donofrio Products is considering whether to upgrade its equipment. Managers are considering two options. Equipment manufactured by Smith costs $850,000 and will last six years and have no residual...
-
Subtract in the indicated base. 10012 1102
-
The company is committed to ethical conduct and has no tolerance for fraud and unethical behavior. There are some concerns about abuses in your department. Do you know anything about the concerns I...
-
During the first month of operations ended July 31, 2014, YoSan Inc. manufactured 2,400 flat panel televisions, of which 2,000 were sold. Operating data for the month are summarized as follows:...
-
n Juods xi(yi - Bxi) = 0 n i=1 a) Step by step, solve for B (Hint: you may want to use the proof starting on pg 10 as your guide)
-
Is Free Expression Abused or More Necessary Than Ever? Explain
-
How has current global events, such as the COVID-19 pandemic and fear of environmental deterioration, affected the state of globalization today? Do you think globalization will continue to thrive or...
-
How does your organization use research? How might your organization expand its use of research? If you are not currently practicing, how do you think organizations should use research?
-
How does rehabilitation theory look in a corrections justice model, medical model, and custodial model?
-
In this activity, you will describe how using critical analysis influences your life and your perspectives. First, you will describe how critical analysis skills have affected your personal...
-
How do you plan to report risk response plan initiation and then track its execution and progress?" discuss the various indications an identified uncertainty has triggered and is now an issue, how...
-
The deployment of airbags during a car accident results from a chemical reaction that, until the 1990s, involved sodium azide, NaN 3 . Sodium azide has since been replaced by less toxic substances...
-
Vectors are drawn from the center of a regular n-sided polygon in the plane to the vertices of the polygon. Show that the sum of the vectors is zero.
-
A firm is considering three mutually exclusive alternatives as part of a production improvement program. The alternatives are as follows: For each alternative, the salvage value at the end of-...
-
A series of monthly cash flows is deposited into an account that earns 12% nominal interest compounded monthly. Each monthly deposit is equal to $2100. The first monthly deposit occurred on June 1,...
-
A million-dollar oil drilling rig has a 6-year depreciable life and a $75,000 salvage value at the end of that time. Determine which one of the following methods provides the preferred depreciation...
-
An investment has the following cash flow series where interest is 5 percent: a. Determine the present worth of the series. b. Determine the future worth of the series at the end of year 8. c. Find...
-
The manager at a Sherwin-Williams store has decided to purchase a new \($30\),000 paint-mixing machine with hi-tech instrumentation for matching color and other components. The machine may be paid...
-
Develop a single spreadsheet that allows you to calculate any of the P|A, A|P F|A, or A|F factors. For each cell where the calculation is performed, place above it a small control panel that allows...
Study smarter with the SolutionInn App