Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java What output is produced by the following code? int[ ][ ] testArray = new int[3][4]; for (int row = 0; row < testArray.length; row++)

Java
  1. What output is produced by the following code?

int[ ][ ] testArray = new int[3][4]; for (int row = 0; row < testArray.length; row++) for (int col = 0; col < testArray[row].length; col++) testArray[row][col] = col; for (int row = 0; row < testArray.length; row++) { for (int col = 0; col < testArray[row].length; col++) System.out.print(testArray[row][col] + " "); System.out.println(); }

2. Write code that will fill the following array a with numbers typed at the keyboard:

int [ ][ ] a = new int[4][5];

3. Write Java programs for following:

  1. To create a 2D array to store numbers. Take the input of the array. Display the contents of the array in the matrix form. Find and display the sum of all elements, sum of all even numbers, and sum of all odd numbers.
  2. To create two 2D arrays and carry out the following operations: sum of the two matrices and difference of the two matrices. Display the matrices in a proper matrix format using a method.
  3. To create a matrix of size of MXN, find the sum of each row, sum of each column and if it is a square matrix then find the sum of diagonal elements also. M and N are user input.
  4. To create a square matrix of order 3x3 containing integers, using a method CREATE( ). The program should then use a function SWAP( ) which swaps two integer values, to find the transpose of the matrix, and display the transpose using a function DISPLAY( ).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil, Elizabeth O'Neil

2nd Edition

1558605800, 978-1558605800

More Books

Students also viewed these Databases questions

Question

What are the stages of project management? Write it in items.

Answered: 1 week ago