
Launch a new series on Java basics that helps every programmer crack any Java interview.
Use the mod operator in Java to determine if a number is even or odd with an if condition and examples using 50 and 51.
Learn to check prime status with a Java program in Eclipse, using 2 to num/2 and a flag to print prime or not. Note 1 is neither prime nor composite.
Learn to generate a Fibonacci series in Java by initializing two variables to 0 and 1, then loop to print the first ten numbers and update values with their sum.
Learn to check Armstrong numbers in Java by calculating the sum of cubes of digits with a loop and mod operations. Validate whether the computed sum matches the original number.
Compute factorials by multiplying numbers from n down to 1 using a reverse for loop in Java. For example, 5! equals 120; 0! equals 1; negative numbers have no factorial.
Reverse a string in Java by converting it to a char array and iterating backward with a for loop to build the reversed string.
Learn how to determine if two strings are anagrams in a Java program by checking equal lengths, converting to lowercase, converting to character arrays, sorting, and comparing.
Find duplicate characters in a string using a Java program. Convert to a char array and use two nested loops with an output array to collect and print duplicates.
Learn to find vowels and consonants in a string with a basic Java program, using arrays to collect letters and count each occurrence, then display results as comma-separated strings.
Discover how Java strings are immutable: assigning causes a new object while the original stays unchanged, demonstrated through input cases using concat and plus operator.
Learn to use the Stream API to move all zeros to the end by partitioning by zero, flattening with flatMap, and collecting results into a single list.
Create a stream from the string list, collect a map of each string to its duplicate character count using identity and grouping by counting, producing the final results.
Explore using Java streams to find duplicates in an integer array by filtering with a frequency function, then collecting duplicates into a set and printing the results.
Generate a stream of random numbers using the stream API by creating a random object, applying a limit, and printing with for each loop using int, long, or double getters.
Group names by length with streams and count each group. Convert the input into a list, stream it, and collect by length to produce a length-to-count map.
Use the stream API to find duplicate characters in a string by counting frequencies, filtering counts greater than one, and collecting keys as a list; information yields i, n, o.
Remove null values from a list using the Stream API by filtering non-null elements and collecting the results into a new list.
Leverage stream api to find the longest string in a list by comparing string lengths, handle empty lists with optional, and produce the result grape fruit.
Calculate the average age from a list of persons using streams, mapping each person to their age and then averaging the results.
Merge two lists using the stream API to produce a single sorted list by concatenating streams and collecting the results.
Leverage the stream API to find the intersection of two sorted integer lists by filtering the first list with contains on the second and collecting the result.
Learn to remove duplicates from an integer list using the Stream API while preserving order. Use distinct and collect to a list to get the final result 123456.
Leverage streams to process a list of transactions, group by date, and sum amounts, producing a map of daily totals using collectors and the transaction class's date and amount getters.
Learn to find the kth smallest element in an array using streams: sort, skip k-1, and find first, with a fallback when k is invalid, illustrated by a 4271536 example.
Harness the stream API to compute word frequencies from a list by grouping. Use function identity and counting, then collect into a map showing banana two, cherry one, apple three.
Use the stream API to partition an integer list into even and odd numbers with a predicate, collect into a map, and print separate lists for true and false results.
Convert an integer list to a string stream, map to string, filter by startswith '1', and collect to reveal numbers starting with one (example output 1015).
Learn to find the maximum value in a list of integers using streams, converting an array to a list, applying the max function with compare, and retrieving the result 98.
group words by their characters using Java streams by sorting each string's characters and grouping by the resulting key; create a map of words that have the same characters.
This course is a building block for any beginner wanting to clear java interviews. It covers all the Java Basic Programs that is a must for every programmer to crack any Java Interview.
In this series, we will discuss following programs in a detail :
1. Find an even or odd number
Odd numbers are those numbers that cannot be divided into two equal parts, whereas even numbers are those numbers that can be divided into two equal parts.
2. Find a prime number
A prime number is a natural number greater than 1 that is not a product of two smaller natural numbers.
3. Fibonacci series
The Fibonacci sequence is a sequence in which each number is the sum of the two preceding ones.
4. Check Armstrong Number
Armstrong number is a number that is equal to the sum of cubes of its digits.
5. Factorial of a number
Factorial of a positive integer (number) is the sum of multiplication of all the integers smaller than that positive integer.
6. Reverse of a string
Reversing a string is the technique that reverses or changes the order of a given string so that the last character of the string becomes the first character of the string and so on.
7. String anagram
An anagram of a string is another string that contains the same characters, only the order of characters can be different.
8. Find duplicate characters in a string
Count the occurrence of a character is more than once in the string, is a duplicate character.
9. Find vowels and consonanats in a string
Vowels include a, e, i, o, u. A consonant is any letter of the alphabet other than the vowels (a, e, i, o, u).
10. String is immutable
A string object that cannot be altered, but the reference to the object can be changed.
Along with the top 10 java interview questions, there a bonus section as well.
Bonus section: 20 Stream API Interview Questions
Move all the zeros at the end
Duplicate characters in a list of string
Duplicates in an integer array
Generate stream of random numbers
Count string by its length
Duplicate characters in a string
Remove null values from a list
Longest string in a list of strings
Average age from a list of persons
Merge two lists into a single sorted list
Common values from two lists
Remove duplicates while preserving order
Sum of transaction amounts for each day
Kth smallest element in an array
Frequency of words in a list
Even and odd numbers in a list
Numbers starting with 1 in a list
Maximum value in a list of integers
First non-repeated character in a string
Group strings with same characters