Home C C++ Java Python Perl PHP SQL JavaScript Linux Online Test Forum

Home » Java » Java Problems on Array for Beginners and Experts

Java Problems on Array for Beginners and Experts

These problems are very useful to improve your Java programming. There are various ways to solved these Java problem but suggestion is to write readable and customized code. Eclipse IDE can be used for writing & compilation of code.


1. Write a Java program that calculate sum of all diagonal elements of 4*4 double dimensional array. Output should be 36
Java program that calculate sum of all diagonal elements
Output: 36

2. Write a Java program to find sum of even and odd number separately
Java program to find sum of even and odd number
Output should be:
Even: 12
Odd: 16

3. Find the length of integer array without using any predefined function
Find the length of integer array
Output: 7

4. Create two arrays with same no of integer element and create third array which contains sum of two arrays
Array1:
integer array in java
Array2:
interger array 2 in java
Output:
sum of integer array in java

5. Write Java code to check if two Integer arrays are identical
Array1:
check if two Integer arrays are identical
Array2:
Java code to check if two Integer arrays are identical
Output: Array are Identical

6. Write Java code to transpose two dimensional array. Program should be able to transpose n*n size
Java code to transpose two dimensional array

7. Write Java code to convert integer [][] to integer[]. Code should support n number of elements.
Java code to convert integer [][] to integer[]


8. Write Java code to reverse a SDM without using any predefined method of Java
Java code to reverse a SDM without using any predefined method


9. Write Java program to short one array using index values which are in another array
Java program to short one array using index values

10. Write Java code to find regions of connected 1’s in DDM (m*n) which is filled of 0 and 1. Here is an example Example 1:-
Java code to find regions of connected 1’s
Answer: Regions of Regions of connected 1s are: 3

Example 2:-
Java code to find regions of connected 1’s in array
Answer: Regions of Regions of connected 1s are: 2

Example 3:-
Tricky problems on arrays in Java
Answer: Regions of Regions of connected 1s are: 2

For any clarification or for more problems please contact admin@cppbuzz.com

If you are new to Java then Solve MCQs first Java MCQs


[Contribute to this Website]