Java Practice Exercise – Arrays

  • Create an array and perform the following operations
    • Display contents of the array
    • Display length of the array
    • Sum of elements in array
    • Smallest element in array
    • Largest element in array
    • Find if given element is present in array
    • Display element in given position in the array
    • Add elements to the array
    • Remove elements from the array
    • Replace elements
    • concatenate two arrays
    • Reverse
    • Sort
  • Write a program to generate the Fibonacci series upto N terms. Store the generated numbers in an array and display it.
  • Given an array containing city names, display the index, name and name length
  • Write a program to read a set of numbers from a user and store in a list. Eliminate duplicate elements
  • Write a program to read two arrays and merge them without duplicates
  • Write a program to display elements from the first array that are not present in the second array
  • Given an array of N numbers, read the element to search in the list. Display the number of occurrences of the element with its position.
  • Given two lists that are sorted in ascending order, write a program to merge the lists into a single list that contains every item from both lists in sorted order.
  • Matrix
    • Addition, subtraction and multiplication of matrices
    • Transpose of a matrix
    • Sum of diagonal elements of a matrix.
    • Sort the elements of a matrix
    • Read an N x N matrix. Check if the last element of each row is the sum of the all other elements in that row