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]
3 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]3 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
All of these are required categories on a safety data sheet except
ale4655 [162]

I think it is D because you would need there contact information in case something happens not there trade name

3 0
3 years ago
Read 2 more answers
What technology gets its name from the notion that it ignores the traditional A, B, and C class designations for IP addresses?
goblinko [34]

Answer:

Classless Inter-Domain Routing

Explanation:

Classless Inter-Domain Routing (CIDR), pronounced “cider” or “sidder,” gets its name from the notion that it ignores the traditional A, B, and C class designations for IPv4 addresses and sets the network-host ID boundary wherever it wants to, in a way that simplifies routing across the resulting IP address spaces.

3 0
2 years ago
What are examples of intermediate goals that require funding? Check all that apply.
SashulF [63]
2.) Attending college
3 0
3 years ago
Read 2 more answers
Briefly explain the importance of doing backup in systems administration and explain in detail any three methods for performing
Dmitry_Shevchenko [17]

Answer:

Importance of backup in system administration:

Backups are crucial in system administrations for preserving continuity and protecting against specific types of hardware failures, service interruptions, and human mistakes. To aid a company in recovering from an unexpected catastrophe, backup copies make it possible to restore data to a previous point in time. To safeguard against primary data loss or corruption, it is essential to save a copies of data on a different media. When a system administrator create a backup, he makes a copy of the data that you can restore if your main data is lost. These errors may be the consequence of faulty hardware or software, corrupted data, or a human error like a targeted attack or an unintentional deletion. System backup and recovery is therefore a crucial skill for system administrators as well as the companies they work for.

Three methods for performing backup:

  1. Disk image: A efficient method to back up not only the files and directories but also everything else on the system is by creating a disk image. If a user have a disk image, the user can restore everything, including the operating system, applications, data, and more, so the user won't have to worry about any difficulties. Placing the  disk image-containing DVD into the DVD-ROM to restore the backup. Additionally, just attach an external HDD to the computer if the user have a disk image that they made.
  2. External hard drive: The most common backup method is to use an external hard drive or even a USB flash drive. An HDD can be easily, quickly, and affordably backed up. It is effective since consumers may carry their portable backup with them wherever they go.
  3. Cloud backup: Cloud backup or Online backup has been around for a while, but not many people really utilize it. But the greatest backup technique by far is cloud backup. The user does not have to worry about hardware problems because their files are saved in the cloud and can be accessed from anywhere because the backups are automatically produced and everything is synchronized. It is one of the greatest methods to backup, especially when you consider that the contents are encrypted and stored securely.

6 0
2 years ago
What is java programing <br>​
sesenic [268]

Answer:

Explanation:

Java is a class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. ... Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of the underlying computer architecture

8 0
3 years ago
Read 2 more answers
Other questions:
  • What is the difference, if any, between a Portable Media Player (PMP) and a Digital Media Device (DMD)? PMPs can be analog or di
    12·1 answer
  • WILL DO A BRAINLY! help pls.
    15·1 answer
  • What are 2 of system software and how are they used?
    11·1 answer
  • CHALLENGE ACTIVITY 4.2.2: Basic while loop with user input. Write an expression that executes the loop while the user enters a n
    14·1 answer
  • Describe the basic features of the relational data model and discuss their importance to the end user and the designer. Describe
    9·1 answer
  • What is the forging of the return address on an email so that the email message appears to come from someone other than the actu
    11·1 answer
  • Why are computers useful for modeling situations?
    13·2 answers
  • The purpose of a switch______link is to be able to carry the traffic for all local VLANs.
    8·1 answer
  • What is a difference between Java and Python? (5 points)
    12·1 answer
  • What is the best scenerio for
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!