Public class Test { public static void main(String[] args) { int[][] values = { {9, 8, 7, 6, 5}, {7,

5 answers
Question:

Public class Test { public static void main(String[] args) { int[][] values = { {9, 8, 7, 6, 5}, {7, 6, 5, 4, 3}, {4, 3, 2, 1, 0}, {4, 3, 2, 1, 0}}; for (int i = 0; i < values. length; i++) { for (int j = i; j < values[i].length; j++) { System. out. print(values[i][j] - values[i+2][j+2]); } System. out. println(); } } }

Answers

The program will output 777 and throw an error of .

Explanation:

The program declare an array called values. It is a multidimensional array. It then try to loops through the array and do some computation.

It has a nested for loop for going through the array.

For the first for-loop the length is 4.

During the computation in the inner loop; Exception thrown is: : Index 5 out of bounds for length 5

The exception is thrown because when i is 3, then values[i+2][j+2] will be values[5][5] and the length of values is 4.

Hi!

The correct answer is d. Neither (a) nor (b) is true.

Explanation:

First, you have to know what the scripts intend to do, and they are counting from 1 to 10 in both cases.

Table of results of class TestA at end of each iteration:

[j = 0,  counter =  1]

[j = 10,  counter =  2]

[j = 20,  counter =  3]

[j = 30,  counter =  4]

[j = 40,  counter =  5]

[j = 50,  counter =  6]

[j = 60,  counter =  7]

[j = 70,  counter =  8]

[j = 80,  counter =  9]

[j = 90,  counter =  10]

Table of results of class TestB at end of each iteration:

[j = 10,  counter =  1]

[j = 9,  counter =  2]

[j = 8,  counter =  3]

[j = 7,  counter =  4]

[j = 6,  counter =  5]

[j = 5,  counter =  6]

[j = 4,  counter =  7]

[j = 3,  counter =  8]

[j = 2,  counter =  9]

[j = 1,  counter =  10]

That's why a) and b) are false.

Maybe you want to know why using pre increments on class TestB doesn't affect the loop. The reason is that when enters in a loop, first checks the test condition and takes the decision if true or false, and last executes the incrementation step.

The answer is "Option d".

Explanation:

In the given code, two class "TestA and TestB" is defined, that calculates some values which can be described as follows:

In class "TestA", three integer variable "x, y, and counter" is declared, that initializes with a value, that is "2, 20, and 0", inside the class for loop is declare that uses variable j which starts from and ends when the value of j is less than 100, it will increment the value of counter variable by 1. In the class "TestB", an integer "counter" variable is initializes a value with 0, inside the class the for loop is used that uses variable j, which starts from 10, and ends when j is less than 0. in the loop it increments the value of "counter" variable by 1.  that's why in this question except "option d" all were wrong.

The J value is just the difference. In this case it is 2130 - 2123.5 = 6.5 Hz. This can get more difficult if a proton is split by more than one another proton, especially if the protons are not identical.

Explanation:

The solution code is written in Python:

i = 2 j = 3 itemp = i jtemp = j  i = jtemp  j = itemp

Explanation:

Given the i and j hold their respective values (e.g. 2 and 3) (Line 1-2). We can create another two more variables itemp and jtemp to hold the values of i and j (Line 3- 4). Next, we assign jtemp to i and itemp to j. This will enable the previous value of j assigned to i and previous value of i assigned to j (Line 5-6).

Similar Solved Works

4 answers

The concentration of an acid or base refers to how completely it dissociates inwater.A. TrueB. False

The concentration of an acid or base refers to how completely it dissociates in water. A. True B. False...
1 answer

I just need help with b. and c. pleasee

I just need help with b. and c. pleasee [tex]I just need help with b. and c. pleasee[/tex]...
4 answers

How to write this numbers in word 1290.301​

How to write this numbers in word 1290.301​...
3 answers

Identify a constant in the equation 18x + 14 = 120 question 3 options: a.18 b. x c. there are no constants in this equation.

Identify a constant in the equation 18x + 14 = 120 question 3 options: a.18 b. x c. there are no constants in this equation. d.14...
4 answers

Complete the equation that relates the number of bottles of soda (b) to the total volume of soda (s) in fluid ounces.s

Complete the equation that relates the number of bottles of soda (b) to the total volume of soda (s) in fluid ounces. s = b...
3 answers

How to calculate standard deviation on excel?

How to calculate standard deviation on excel?...
3 answers

Read this passage from beowulf

Read this passage from beowulf...
9 answers

The difference between 2 numbers is 12. the larger number is 3 times the smaller. what are the numbers

the difference between 2 numbers is 12. the larger number is 3 times the smaller. what are the numbers...
4 answers

In the V vs T graph the line is flat(horizontal) because?

In the V vs T graph the line is flat(horizontal) because?...
5 answers

Before running for president, clinton was the governor of which state?

Before running for president, clinton was the governor of which state?...
4 answers

Henry of Navarre, Elizabeth I, and William of Orange were all politiques. What did the term mean and why does it apply to these

Henry of Navarre, Elizabeth I, and William of Orange were all politiques. What did the term mean and why does it apply to these three rulers?...
7 answers

Who became president in 1845 with plans to expand american territory?

Who became president in 1845 with plans to expand american territory?...
3 answers

Avector a is added to b=6 i – 8 j . the resultant vector is in the positive x direction and has a magnitude equal to a.

Avector a is added to b=6 i – 8 j . the resultant vector is in the positive x direction and has a magnitude equal to a. calculate the direction of a....
10 answers

I am not driving down with you anymore thanks for taking me all those times. Sentence fragment or run

I am not driving down with you anymore thanks for taking me all those times. Sentence fragment or run on...
2 answers

Express as a unit rate. $120 for 5 days of work​

Express as a unit rate. $120 for 5 days of work​...
4 answers

Please helpJohn had his annual physical with his physician and after receiving his blood work results, his doctor is concerned. John’s total cholesterol

Please help John had his annual physical with his physician and after receiving his blood work results, his doctor is concerned. John’s total cholesterol is 309. His HDL is 25 and his LDL is 220. His triglycerides are 320. John eats fast food every day, usually twice per day. His favorite restaur...
4 answers

What is the resistance in a circuit that has a current of 0.75A and a voltage drop of 60V across the cell?( Please help) I will give brainliest

What is the resistance in a circuit that has a current of 0.75A and a voltage drop of 60V across the cell?( Please help) I will give brainliest...
10 answers

In the 17th century, British biologist Robert Hooke discovered the cell. A little more than a century

In the 17th century, British biologist Robert Hooke discovered the cell. A little more than a century later, French botanist René Henri Dutrochet concluded that all living things arise from cells, and all cells are derived from other cells. Dutrochet's proposal indicates that — A cells are the h...
4 answers

What is (9m)4 without exponents

What is (9m)4 without exponents...
4 answers

Anime suggestions 0.0

Anime suggestions 0.0...

-- 0.060213--