1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
MAXImum [283]
4 years ago
6

Assume arr2 is declared as a two-dimensional array of integers. Which of the following segments of code successfully calculates

the sum of all elements arr2?
A.int sum = 0;for(int j = 0; j < arr2.length; j++){ for(int k = 0; k < arr2[j].length; k++) { sum += arr2[k][j]; }}
B.
int sum = 0;for(int j = arr2.length − 1; j >= 0; j−−){ for(int k = 0; k < arr2[j].length; k++) { sum += arr2[j][k]; }}
C.
int sum = 0;for(int[] m : arr2){ for(int n : m) { sum += n; }}
Computers and Technology
1 answer:
Delvig [45]4 years ago
3 0

Answer:

int sum = 0;for(int[] m : arr2){ for(int n : m) { sum += n; }}

Explanation:

Option A is wrong because it will throw an ArrayIndexOutOfBoundsException during the last iteration of the first and second loop.

the number of accessible element in the first dimension of arr2 is from 0 to arr2.length-1 but the loop specify 0 to arr2.length which will be the first cause of the error

while that of the second dimension specify 0 to arr2[j].length  instead of 0 to arr2[j].length-1

Option B is also wrong because the expression j-- will decrement the value of j instead of incrementing it and the second dimension specify 0 to arr2[j].length  instead of 0 to arr2[j].length-1 which will also cause an ArrayIndexOutOfBoundsException.

Option C will successfully calculates the sum of all elements arr2.

You might be interested in
Sean is white hat hacker, who is demonstrating a network level session hijack attacks and as part of it, he has injected malicio
solong [7]

Answer:

The following network level session hijacking attack shown by Sean is Blind Hijacking, LETTER C.

Explanation:

<em>Because he is injecting malicious data or commands into the intercepted communications in the TCP session even if the source-routing is disabled. He can send the data or commands but hass no access to see the response.</em>

3 0
4 years ago
True or false? LearnSmart (the "smart flash card assignments") really gets your competitive spirit in gear by allowing you to se
vfiekz [6]
<h2>Answer:</h2>

The following statement is TRUE.

LearnSmart (the "smart flash card assignments") really gets your competitive spirit in gear by allowing you to see where you stand as compared to your classmates in terms of your mastery of grammar and vocabulary concepts.

<h2>Explanation:</h2>

LearnSmart is an adaptive technology that is helping a lot of students by letting them judge which parts/topics of the book are not clearly learnt by them and which of them are under their grip.

LearnSmart provides cards with short term questions that make i possible for students to complete their preparation in short time. In addition to this smart flash card assignments are a to compare students preparation relatively.

<h3>I hope it will help you!</h3>
4 0
3 years ago
What role do computer play in law and order​
kirza4 [7]

Computers on Law & Order tracks computers and computer use through all 456 episodes of the American crime drama Law & Order.

Explanation:

5 0
3 years ago
Is windows CUI operating system??<br><br><br>What is the main purpose of folder ????<br><br><br>​
Likurg_2 [28]
Answer: yes and main purpose of folder can help in storing and organizing files and data in the computer.

Hope this helped!
8 0
3 years ago
A DSS8440 server is equipped with one power supply that is failing and requires replacement. What is the correct sequence of ste
Alisiya [41]

Answer:

ICICI oxidized sicken o'clock o'clock succinct

6 0
3 years ago
Other questions:
  • You've been asked to find the average of a range of numbers. Which of the following could you use to find the average of cells A
    9·1 answer
  • Add a throw statement to the processNumbers function that throws the message "All elements in the list should be numbers." if on
    12·1 answer
  • Using the Adjust group, what can you control to affect an image? Check all that apply.
    15·2 answers
  • Many of the special staff teams require leadership training, which is offered to staff with more than 1 year of service at Camp
    15·1 answer
  • What is the standard markup language of the world wide web?
    14·1 answer
  • A bank uses a computer program during the night to tell if the alarm should ring. Sensors in the bank set the following Boolean
    5·1 answer
  • You’re browsing the internet and realize your browser is not responding. Which of the following will allow you to immediately ex
    11·1 answer
  • Write a method that takes in a String and returns a new
    15·1 answer
  • B) Develop a truth table for expression AB+ C.
    10·1 answer
  • Does putting a glue stick on your touchpad make it stop working pls help
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!