Are you looking for the most frequently asked Java coding interview questions for your preparation? If yes, you are at the right place! This website (blog post site) javaicebreakers.com, provides most of the top Java coding interview questions along with more than two solutions for each coding question. You see a table below for each question with headers ‘Using Java Features’ , ‘Happy path Solution’ and ‘Combo Happy path Solutions‘; each row contains a link to the Happy path solution using that respective Java version features. This Happy path solution is easily understood by novice or intermediate programmers. The idea is to ensure that you can revise most of the Java language features for each Java coding question. The existing code solutions provided under the header ‘Happy path Solution’ covers Java features till ‘Java 7’. The code solutions provided under the header ‘Combo Happy path Solutions‘ covers maximum features of ‘Java 8’ along with Unit test scripts for the same ‘Java 8’ solution written in ‘JUnit5‘. The code solutions for ‘Java8 :: JUnit5’ are in still in progress. I wish you all the best and Good luck.
- How to check whether the given strings or sentences are Anagram or not?
| Using Java Features | Happy path Solution (Till Java 7) | Combo Happy path Solutions ( Java 8 ) :: JUnit |
| Using String’s Class | Solution | Code :: Junit5 Code |
| StringBuilder’s Class | Solution | |
| HashMap | Solution | |
| Lambda expression | Solution | |
| All Solutions | All |
- How to find 1st & the 2nd biggest numbers in an Array or an ArrayList of Integers?
| Using Java Features | Happy path Solution (Till Java 7) | Combo Happy path Solutions ( Java 8 ) :: JUnit |
| Using Arrays core logic | Solution | Code :: Junit5 Code |
| Sort | Solution | |
| stream | Solution | |
| ArrayList | Solution | |
| All Solutions | All |
- How to find duplicate words in a given sentence?
| Using Java Features | Happy path Solution (Till Java 7) | Combo Happy path Solutions ( Java 8 ) :: JUnit |
| Using String’s Class | Solution | Code :: Junit5 Code |
| HashMap | Solution | |
| Collections | Solution | |
| All Solutions | All |
- How to remove duplicate numbers from an array of integers?
| Using Java Features | Happy path Solution |
| Using Arrays | Solution |
| HashSet | Solution |
| Stream | Solution |
| All Solutions | All |
- How to reverse each word in a given sentence?
| Using Java Features | Happy path Solution (Till Java 7) | Combo Happy path Solutions ( Java 8 ) :: JUnit |
| Using StringBuffer | Solution | Code :: Junit5 Code |
| Strings | Solution | |
| Lambda expression | Solution | |
| stream | Solution |
- How to reverse an Integer value?
| Using Java Features | Happy path Solution |
| Using Corelogic | Solution |
| Using StringBuffer | Solution |
| Strings | Solution |
| Generics | Solution |
- How to find the sum of integers in an Array or Array List?
| Using Java Features | Happy path Solution |
| Using simple Array | Solution |
| ArrayList (Iterator & listIterator) | Solution |
| stream | Solution |
- How to find the sum of digits in an alphanumeric value ?
| Using Java Features | Happy path Solution (Till Java 7) | Combo Happy path Solutions ( Java 8 ) :: JUnit |
| Using String’s class | Solution | Code :: Junit5 Code |
| Lambda expression | Solution | |
| stream | Solution |
- How to find the sum of digits in an Integer?
| Using Java Features | Happy path Solution | Combo Happy path Solutions ( Java 8 ) :: JUnit |
| Using Core logic | Solution | Code :: Junit5 Code |
| Lambda expression | Solution | |
| stream | Solution |
- How to move all Zeros to the end of an array?
| Using Java Features | Happy path Solution |
| Using Arrays (Original) | Solution |
| Additional temp Array | Solution |
| stream | Solution |
- How to find min & max length strings in a given sentence of strings?
| Using Java Features | Happy path Solution (Till Java 7) | Combo Happy path Solutions ( Java 8 ) :: JUnit |
| Using Core logic | Solution | Code :: Junit5 Code |
| Hashmaps | Solution | |
| stream | Solution |
- How to find pairs of numbers whose sum is divisible by 9 in an array?
| Using Java Features | Happy path Solution (Till Java 7) | Combo Happy path Solutions ( Java 8 ) :: JUnit |
| Using Arrays, Lists | Solution | Code :: Junit5 Code |
| Arrays, Predicate | Solution | |
| Stream | Solution |
- How to find triplets of numbers whose sum is divisible by 9 in an array?
| Using Java Features | Happy path Solution (Till Java 7) | Combo Happy path Solutions ( Java 8 ) :: JUnit |
| Using Arrays, Lists | Solution | Code :: Junit5 Code |
| Arrays, Predicate | Solution | |
| Stream | Solution |
- How to find the factorial of a number?
| Using Java Features | Happy path Solution (Till Java 7) | Combo Happy path Solutions ( Java 8 ) :: JUnit |
| Using Core logic | Solution | Code :: Junit5 Code |
| Big Integer | Solution | |
| Recursion | Solution | |
| Stream | Solution | |
| Multithreads | Solution | |
| All Solutions | All |
- How to check whether a given integer is a Prime number or not?
| Using Java Features | Happy path Solution (Till Java 7) | Combo Happy path Solutions ( Java 8 ) :: JUnit |
| Using Corelogic | Solution | Code :: Junit5 Code |
| Core logic, Predicate | Solution | |
| Lambda expression | Solution | |
| All Solutions | Solution |
- How to reverse the numbers at even positions in an array of integers?
| Using Java Features | Happy path Solution |
| Using Same Array | Solution |
- How to check whether a given number is Disarium or not?
- How to find subsets or substrings of a given String?
| Using Java Features | Happy path Solution (Till Java 7) | Combo Happy path Solutions ( Java 8 ) :: JUnit |
| Using Strings | Solution | Code :: Junit5 Code |
| String Builder | Solution | |
| Lambda expression | Solution | |
| Multithreads | Solution | |
| All Solutions | All |
- How to find the Nth largest number from an array of integers?
| Using Java Features | Happy path Solution (Till Java 7) | Combo Happy path Solutions ( Java 8 ) :: JUnit |
| Using Arrays Sort | Solution | Code :: Junit5 Code |
| Lambda expression, Arrays Sort | Solution | |
| Generic functional interface, Lambda expressions, Arrays Sort | Solution | |
| Stream | Solution |
- How to extract characters and numbers from an Alphanumeric value?
| Using Java Features | Happy path Solution (Till Java 7) | Combo Happy path Solutions ( Java 8 ) :: JUnit |
| Using Character Class | Solution | Code :: JUnit5 Code |
| ASCII range check | Solution | |
| predicates & chain of predicates | Solution | |
| All Solutions | All |
- How to find array triplets where the sum of two numbers equals the other number of an array?
| Using Java Features | Happy path Solution |
| Using Arrays | Solution |
| Lambda expression, Arrays | Solution |
| stream | Solution |
| All Solutions | Solution |
- How to check whether a given number is Armstrong or not?
| Using Java Features | Happy path Solution (Till Java 7) | Combo Happy path Solutions ( Java 8 ) :: JUnit |
| Using String, and Character class | Solution | Code :: JUnit5 Code |
| Core logic | Solution | |
| Streams | Solution |
- How to print Floyd’s Triangle?
| Using Java Features | Happy path Solution |
| Using Core logic | Solution |
- How to find the nTh value in the Fibonacci series?
| Using Java Features | Happy path Solution (Till Java 7) | Combo Happy path Solutions ( Java 8 ) :: JUnit |
| Using Core logic | Solution | Code :: JUnit5 Code |
| Recursion | Solution | |
| Multithreads | Solution | |
| Stream | Solution | |
| All Solutions | Solution |
- How to check whether a string can be eligible to form a palindrome?
| Using Java Features | Happy path Solution (Till Java 7) | Combo Happy path Solutions ( Java 8 ) :: JUnit |
| Using Core logic | Solution | Code :: JUnit5 Code |
| Hashmap | Solution | |
| StringBuffer | Solution | |
| All Solutions | All |
- How to count the number of occurrences of a given word in a file?
| Using Java Features | Happy path Solution |
| Using FileReader, and StringBuffer class | Solution |
| FileReader, and String class | Solution |
- How to reverse all the numbers in an array of integers?
| Using Java Features | Happy path Solution |
| Using Arrays, Core logic | Solution |
| Generics | Solution |
| Stream | Solution |
- How do you find and replace the given string with a new one in a given file?
| Using Java Features | Happy path Solution |
| Using Files, and StringBuffer class | Solution |
| Files, and String class | Solution |
- How to find strings with no Vowels in a file?
| Using Java Features | Happy path Solution |
| Using Files, StringTokenizer and StringBuffer class | Solution |
| Files, and Regex class | Solution |
- How to count lines, words, and characters in a file?
| Using Java Features | Happy path Solution |
| Using Files, String Tokenizer, and String | Solution |
- How to check whether a String is a Palindrome or not?
| Using Java Features | Happy path Solution | Combo Happy path Solutions ( Java 8 ) :: JUnit |
| Using Lambda expression, and StringBuffer | Solution | Code :: Junit5 Code |
| Lambda expression, and String | Solution | |
| All Solutions | Solution |
- How to check whether any number in an array is repeated twice or thrice?
| Using Java Features | Happy path Solution (Till Java 7) | Combo Happy path Solutions ( Java 8 ) :: JUnit |
| Using HashMap | Solution | Code :: Junit5 Code |
| Collections | Solution | |
| Lambda expression | Solution | |
| All Solutions | All |
- How to find the intersection values of two Arrays?
| Using Java Features | Happy path Solution |
| Using Arrays, StringBuilder | Solution |
| Generics, Arrays, StringBuilder | Solution |
| Lambda expression, Arrays, StringBuilder | Solution |
- How to find Missing prime numbers from any given sequence of integers?
- How to find leader numbers from any given array of integers?
| Using Java Features | Happy path Solution (Till Java 7) | Combo Happy path Solutions ( Java 8 ) :: JUnit |
| Using Arrays | Solution | Code :: Junit5 Code |
| Using Arrays | Solution | |
| stream | Solution |
Having more questions for which you need solutions? Please let us know using the form below.
