Java Interview Programs



I have been posting java interview programs on various topics such as Binary tree, LinkedList , String, Number, ArrayList, HashMap etc. So I am consolidating list of java interview programs to create an index post. I will keep adding links to this post whenever I add any new program. These are frequently asked java programs in interview. You can also go through top 50 java interview questions for interview questions.

Java interview programs


Java collections APIs provides lots of inbuilt classes and interfaces to handle collections of objects. Here is list of most asked java interview programs on Collections.

  1. Collections interview questions and answers
  2. How HashMap internally works in java
  3. How HashSet works interanlly in java
  4. How to iterate over HashMap in java
  5. How to Sort ArrayList based on attributes using Comparator in java
  6. How to sort ArrayList based on attributes using Comparable in java
  7. How to remove duplicates from list in java
  8. How to iterate over ArrayList in java


  1. Multithreading interview questions and answers
  2. Print even odd number using 2 threads
  3. Print sequence using 3 threads
  4. Custom BlockingQueue implementation in java

Java 8

  1. Java 8 interview questions
  2. Implement lambda expressions in java 8
  3. Filter Stream in java 8
  4. Implement Parallel Stream in java 8
  5. Avoid NullpointerException using Optional


String is most used data structure in java. There are lot of java interview programs on String which can be asked in interview.

  1. How to reverse String in java
  2. How to check if two Strings are angrams
  3. Find length of String without using java inbuilt length method
  4. Find all substrings of String in java
  5. Find First non repeated character in a String
  6. Java Program to check Palindrome String
  7. Why String is immutable in java
  8. Find duplicate characters in String
  9. Longest common prefix in array of Strings


There are many java tricky  interview programs that can be asked in interview.

You should practice these java interview programs on array.

    1. Find smallest and largest element in array
    2. Find second largest number in array
    3. Find missing number in an array
    4. Separate 0’s and 1’s in array
    5. Separate odd even numbers in java
    6. Sort array of 0’s, 1’s and 2’s in java
    7. Find number occurring odd number of times in array
    8. Minimum numbers of platforms required for railway station in java
    9. Find pair whose sum is closest to zero in array in java
    10. Find pair whose sum is closest to X in array in java
    11. Find all pairs of elements whose sum is equal to given number
    12. Search element in row wise and column wise sorted matrix
    13. Stock buy and sell to maximize profit.
    14. Find local minima in array
    15. Find leader in array
    16. Find subarray with given sum
    17. Sliding window maximum
    18. Find peak element in array
    19. Permutations of array in java
    20. Subsets of set
    21. Rotate array by K positions
    22. Largest sum contiguous subarray
    23. search an element in a sorted and rotated arraybinary in java
    24. Minimum element in a sorted and ratated array in java
    25. Minimum jumps required to reach end of array


It is one of the most used data structure. In singly linked list, Node has data and pointer to next node. It does not have pointer to the previous node. Last node ‘s next points to null, so you can iterate over linked list by using this condition.

  1. How to reverse a linked list in java
  2. How to reverse a linked list in pairs
  3. How to find middle element of linked list in java
  4. How to detect a loop in linked list in java
  5. Find start node of loop in linkedlist
  6. How to find nth element from end of linked list
  7. How to check if linked list is palindrome in java
  8. Add two numbers represented by linked list in java
  9. Find intersection of two Linked Lists

Binary tree

A binary tree is a tree data structure in which each node has at most two children, which are referred to as the left child and the right child. Here is list of Java interview programs asked on binary tree.

  1. Binary tree in java
  2. Binary tree preorder traversal
  3. Binary tree postorder traversal
  4. Binary tree inorder traversal
  5. Binary tree level order traversal
  6. Binary tree spiral order traversal
  7. Binary tree reverse level order traversal
  8. Binary tree boundary traversal
  9. Print leaf nodes of binary tree
  10. Count leaf nodes in binary tree
  11. get maximum element in binary tree
  12. Print all paths from root to leaf in binary tree
  13. Print vertical sum of binary tree in java
  14. Get level of node in binary tree in java
  15. Lowest common ancestor(LCA) in binary tree in java

Binary search tree

  1. Binary search tree in java
  2. Delete node from binary search tree
  3. Minimum and maximum elements in binary search tree
  4. LCA of binary search tree
  5. inorder successor in binary search tre
  6. Conver sorted array to balanced BST
  7. Convert sorted Linked List to balanced BST
  8. Convert sorted Linked List to balanced BST
  9. Check if a binary tree is binary search tree or not in java


  1. Implement merge sort
  2. Implement bubble sort
  3. Implement insertion sort
  4. Implement quick sort
  5. Implement heap sort
  6. Implement selection sort
  7. Implement shell sort
  8. Implement counting sort


  1. How to swap two numbers without using temporary variables
  2. Java program to check prime number
  3. Find prime factors of number in java
  4. Java Program to check armstrong number
  5. Fibonacci series program in java
  6. Java Program to check Palindrome Number
  7. Java Program to to find gcd and lcm of two numbers
  8. Check if String is number in java
  9. Print prime numbers from 1 to 100


  1. How to calculate complexity of algorithm
  2. Binary Search in java

That’s all about java interview programs. If you can also go through C interview programs.
Refer Core java tutorial for more such tutorials.



  1. Shyam Agrawal August 28, 2015
  2. S.K.Mahalingam April 18, 2016
    • arpitmandliya April 29, 2016
  3. akshay gupta June 13, 2016
  4. Muppalla Sireesha July 20, 2016
  5. Ram Sharan March 23, 2017
    • Arpit Mandliya March 23, 2017
      • Akshay December 14, 2019
  6. Ashok March 24, 2017
  7. nitin March 30, 2017
  8. Avish September 8, 2017
  9. Chandra May 24, 2018
  10. Saikiran July 26, 2018
  11. Ohayo January 6, 2020

Add Comment