Question: What will be the output of following code? int [ ] [ ] twoDArray { 1 , 2 , 3 } , { 4 ,

What will be the output of following code?
int [][] twoDArray
{1,2,3},
{4,5,6},
{7,8,9}
};
int evensum =0;
for (int i=0; i twoDArray. length; i++){
for (int j=0;j twoDArray [i]. length; j++){
if (twoDArray[i][j]%2==0){
evenSum += twoDArray [i][j];
}
}
}
System.out.println("Sum of all even numbers: "+ evenSum);
Sum of all even numbers: 22
Sum of all even numbers: 18
Sum of all even numbers: 24
Sum of all even numbers: 20
AGU
What is the repeating pattern?
Assumption
Initial state: QAQBQCQDQE=00000
 What will be the output of following code? int [][] twoDArray

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!