1 answer

Q21 Read the following code: 8 Points public class Main { public static int[][] doStuff() {...

Question:

Q21 Read the following code: 8 Points public class Main { public static int[][] doStuff() { int[][] array2D = new int[3][2];

Q21 Read the following code: 8 Points public class Main { public static int[][] doStuff() { int[][] array2D = new int[3][2]; for (int i = 0; i < array2D.length; i++) { for (int j = 0; j < array2D[0].length; j++) { array2D[i][j] = (i+j)%2; } } return array2D; فه public static void main(String[] args) { int[][] a = doStuff(); مہ سره Q21.1 What are the contents of array a? 6 Points Write your answer as if printing the elements row-by-row. E.g.: 1 2 3 4 5 6 7 8 9 Enter your answer here Q21.2 The array returned by method do Stuff is 3x2 (3 rows by 2 columns). What changes do you need make to method do Stuff to make the 2D array 2x5? 2 Points Assume the line array2D[i][j] = (i+j)%2; is correct and doesn't need to be changed. Enter your answer here

Answers

21.1

The contents of the array a are:

0 1

1 0

0 1

21.2

To changes needed in the method doStuff to make an array of 2X5 is to update the array declaration as:

int [][] array2D = new int [2][5];

The changed method will be

public static int[][] doStuff()
{
//changing the array declaration
int[][] array2D = new int[2][5];
for(int i=0; i< array2D.length; i++)
{
for(int j=0;j<array2D[0].length;j++)
{
array2D[i][j]=(i+j)%2;
}
}
return array2D;
}

.

Similar Solved Questions

1 answer
Find the magnitude of the gravitational force on Mars, with a mass of 6.34 × 10 23 kg and a...
Find the magnitude of the gravitational forceon Mars, with a mass of 6.34 × 1023kg and aradius of 3.43 × 106 m.Answer in units of N...
1 answer
Compute the Jacobian J(u, v) for the following transformation. x = 4u, y= - v J(u,...
Compute the Jacobian J(u, v) for the following transformation. x = 4u, y= - v J(u, v) = (Simplify your answer.)...
1 answer
Table 3.1 Individual Demand and Supply Schedules Market Quantity Demanded by Alejandro Ben Carl 8 4...
Table 3.1 Individual Demand and Supply Schedules Market Quantity Demanded by Alejandro Ben Carl 8 4 2 12 4 4 20 4 6 22 4 6 Price $8.00 6.00 4.80 2.00 1 Quantity Supplied by Price Avery Brandon Cassandra $8.89604 6 56.00 42 4 4 54.00 24 4 2 $2.00 6 4 In Table 3.1. if government held the price at Mult...
1 answer
For each system listed in the first column of the table below, decide (if possible) whether...
For each system listed in the first column of the table below, decide (if possible) whether the change described in the second column will increase the entropy S of the system, decrease S, or leave S unchanged. If you don't have enough information to decide, check the "not enough information...
1 answer
QUESTION 57 Anne and Andy had been engaging in unprotected sex for over a year. They...
QUESTION 57 Anne and Andy had been engaging in unprotected sex for over a year. They both appeared healthy. A few days ago Anne experienced dysuria, an odorless, yellow vaginal discharge, burning, itching, abdominal pain, and sex was painful. She went to the doctor and found that the organism causin...
1 answer
25% of Lings savings is the same amount as 20% of Neil's savings
25% of Lings savings is the same amount as 20% of Neil's savings. Find the ratio of Lings's savings to Neil's savings....
1 answer
Part B short answer: (30 points). Show your work clearly and write your answers in the space provided. Report answer...
Part B short answer: (30 points). Show your work clearly and write your answers in the space provided. Report answers with units where possible. 1 A. (5 points) A solution is pre cd(OH)2 (Kp 2.5 x 10) precipitate from this solution, and d by adding 400.0 mL of 2 x 10 M Cd(NO,) and 500.0 mL of 3 x 1o...
1 answer
The objective of this exercise is learning how to parse and analyze the logs on a...
The objective of this exercise is learning how to parse and analyze the logs on a Windows Operating System during an incident response investigation. 4.Create a table in your word document with the 1st 6 lines from the output created from your log2timeline. Please show steps!!...
1 answer
How has the presence of multiple cores on the more recent computer systems affected the way...
How has the presence of multiple cores on the more recent computer systems affected the way you write software? Describe the techniques you use to take advantage of the additional cores and the degree to which you benefit from the more powerful multi-core systems and describe any problems you may ha...
1 answer
Is this structure chiral? Br
Is this structure chiral? Br...
1 answer
At what pressure does ethane (C2H6) have a density of 37.2 g/L at 40°C?
At what pressure does ethane (C2H6) have a density of 37.2 g/L at 40°C?...
1 answer
#3: Frank's Factories has a staff of sales people like Anthony, who receives a monthly salary...
#3: Frank's Factories has a staff of sales people like Anthony, who receives a monthly salary of $2,750.00 plus an incremental commission based on the table below. If he sells $27,300.00, what is his total gross pay for the month? Sales Volume 8,201-15,000 Over 15.000 Commission Rate 4.1% Level ...
1 answer
An economist looks at rent controlled prices as an example of a price ceiling O equilibrium....
An economist looks at rent controlled prices as an example of a price ceiling O equilibrium. price floor @ engaged price. QUESTION 7 The "work effort argument" criticizing traditional economic analyses of the minimum wage implies increased real GDP should result from any increase in the nomi...
1 answer
What is the sphincter of Oddi? What is the ileocecal sphincter?
What is the sphincter of Oddi? What is the ileocecal sphincter?...
1 answer
Why is sucrose and starch tested positive to Benedict"s solution after heating even they are not...
why is sucrose and starch tested positive to Benedict"s solution after heating even they are not reducing sugars?...
1 answer
- + ~ [ Fit to page 1 11. Hess's Law - Calculate the enthalpy for...
- + ~ [ Fit to page 1 11. Hess's Law - Calculate the enthalpy for the following reaction (20 pts) 11.1. NzH4 (1) ► N; (g) + 2H; (g)AH = ? Consider that N2H4 (1) +02 → N(g) + H20 (g), AH = -543.2 kJ 2H2(g) + O2 → H20 (g), AH = -241.8 kJ...
1 answer
Draw an appropriate tree diagram, and use the multiplication principle to calculate the probabili...
Draw an appropriate tree diagram, and use the multiplication principle to calculate the probabilities of all the outcomes. HINT [See Example 3.] There is a 30% chance of rain today and a 20% chance of rain tomorrow. Assume that the event that it rains today is independent of the event that it rains ...
1 answer
You purchase an annuity investment that pays you a lump sum amount of $289,284 at the...
You purchase an annuity investment that pays you a lump sum amount of $289,284 at the end of the term. You must make $20,000 quarterly payments until the end of the term. If you earn an interest rate of 2%, how many of these quarterly payments must you make? (Round to the nearest whole number)...
1 answer
1. The velocity in a certain two-dimensional flow field is given by the equation -= 2zt의...
1. The velocity in a certain two-dimensional flow field is given by the equation -= 2zt의 _ 2yte2 where the velocity is in ft/s when x, y, and t are in feet and seconds, respectively. Determine expressions for the local and convective components of acceleration in the x and y direc tions. What...