
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.
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.