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.
Table of Contents
Java interview programs
Collections
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.
- Collections interview questions and answers
- How HashMap internally works in java
- How HashSet works interanlly in java
- How to iterate over HashMap in java
- How to Sort ArrayList based on attributes using Comparator in java
- How to sort ArrayList based on attributes using Comparable in java
- How to remove duplicates from list in java
- How to iterate over ArrayList in java
Multithreading
Java 8
String
String is most used data structure in java. There are lot of java interview programs on String which can be asked in interview.
- How to reverse String in java
- How to check if two Strings are angrams
- Find length of String without using java inbuilt length method
- Find all substrings of String in java
- Find First non repeated character in a String
- Java Program to check Palindrome String
- Why String is immutable in java
- Find duplicate characters in String
- Longest common prefix in array of Strings
Array
There are many java tricky  interview programs that can be asked in interview.
You should practice these java interview programs on array.
- Find smallest and largest element in array
- Find second largest number in array
- Find missing number in an array
- Separate 0’s and 1’s in array
- Separate odd even numbers in java
- Sort array of 0’s, 1’s and 2’s in java
- Find number occurring odd number of times in array
- Minimum numbers of platforms required for railway station in java
- Find pair whose sum is closest to zero in array in java
- Find pair whose sum is closest to X in array in java
- Find all pairs of elements whose sum is equal to given number
- Search element in row wise and column wise sorted matrix
- Stock buy and sell to maximize profit.
- Find local minima in array
- Find leader in array
- Find subarray with given sum
- Sliding window maximum
- Find peak element in array
- Permutations of array in java
- Subsets of set
- Rotate array by K positions
- Largest sum contiguous subarray
- search an element in a sorted and rotated arraybinary in java
- Minimum element in a sorted and ratated array in java
- Minimum jumps required to reach end of array
LinkedList
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.
- How to reverse a linked list in java
- How to reverse a linked list in pairs
- How to find middle element of linked list in java
- How to detect a loop in linked list in java
- Find start node of loop in linkedlist
- How to find nth element from end of linked list
- How to check if linked list is palindrome in java
- Add two numbers represented by linked list in java
- 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.
- Binary tree in java
- Binary tree preorder traversal
- Binary tree postorder traversal
- Binary tree inorder traversal
- Binary tree level order traversal
- Binary tree spiral order traversal
- Binary tree reverse level order traversal
- Binary tree boundary traversal
- Print leaf nodes of binary tree
- Count leaf nodes in binary tree
- get maximum element in binary tree
- Print all paths from root to leaf in binary tree
- Print vertical sum of binary tree in java
- Get level of node in binary tree in java
- Lowest common ancestor(LCA) in binary tree in java
Binary search tree
- Binary search tree in java
- Delete node from binary search tree
- Minimum and maximum elements in binary search tree
- LCA of binary search tree
- inorder successor in binary search tre
- Conver sorted array to balanced BST
- Convert sorted Linked List to balanced BST
- Convert sorted Linked List to balanced BST
- Check if a binary tree is binary search tree or not in java
Sorting
Number
- How to swap two numbers without using temporary variables
- Java program to check prime number
- Find prime factors of number in java
- Java Program to check armstrong number
- Fibonacci series program in java
- Java Program to check Palindrome Number
- Java Program to to find gcd and lcm of two numbers
- Check if String is number in java
- Print prime numbers from 1 to 100
That’s all about java interview programs. If you can also go through C interview programs.
Refer Core java tutorial for more such tutorials.
Nice Article
with help of your website i learn java based web services
Heartfull thanks for your articles.
Thank you, I am glad that it helped you 🙂
These things are very helpful for anyone.
very helpful
Hi, the article is awesome, I learnt a lot from your blog. This UI is much better than before.
Plz add more interview programming questions to collections in the “Interview Program” section.
Thank you for the feedback. I was working on this UI from last 10 days, I am very glad to hear that it is looking better than previous one.If you want any further improvement, please let me know.
I will surely add more interview questions and will let you know.
Amazing website guys……it is really helpful… thank you so much…..best website for java i have ever seen…
Thank you very much learnt lot more here,
can yoy please provide the algorithim for Sorting LINKED LIST
Hi, the article is awesome, I learnt a lot from your blog. could you plzz upload spring boot ,spring batch and node js topic.
Respect for you.
Really helpful website.
Thank you so much
I love your website and it helped me lot .
Thank you so much
HelpFul
ohayo guziamas. This was really helpful tnks
good exaplanation and undestanding easily ….thanks for website maintainers.
good explanation andeasily understanding thanks