Top Java Interview Programs

Fibonacci series

Fibonacci Series is one of the basic questions in Java., to check the programmer has a basic understanding of logic implementation in java.

In Fibonacci series, the current number is always the sum of previous two numbers.

Fibonacci series is initialized with 0 & 1.

0, 1, (0+1)2, (1+2)3, (2+3)5, (3+5)8, (5+8)13….


0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181

Palindrome String In Java

What is Palindrome?

A Palidrome string is a string where if we reverse the string, the word will be same.

A palindrome is a word, number, phrase, or other sequence of characters which reads the same backward as forward.

Example: madam, refer, redivider

The logic in Java for implementation is very simple.,

  1. Reverse the string
  2. Compare the reversed string with the input string,
    1. If it is same, then Palidrome String
    2. Else not a Palindrome String.


Input String: abcdcba , Reversed String: abcdcba
Is String 1 Palindrome : true
Input String: abcde , Reversed String: edcba
Is String 2 Palindrome : false
Input String: madam , Reversed String: madam
Is String 3 Palindrome : true
Input String: refer , Reversed String: refer
Is String 4 Palindrome : true
Input String: hello , Reversed String: olleh
Is String 5 Palindrome : false

Armstrong Number In Java

Armstrong Number is a number that is the sum of its own digits each raised to the power of the number of digits.


13+53+33=153 which is same as given number 153., and 3 is the number of digits.

14+64+34+44=1634 which is same as given number 1634., and 4 is the number of digits.


Is 153 ArmsStrong Number: true
Is 1634 ArmsStrong Number: true
Is 93084 ArmsStrong Number: true
Is 9800817 ArmsStrong Number: true
Is 407 ArmsStrong Number: true
Is 406 ArmsStrong Number: false

Anagram In Java

 Any word or phrase that exactly reproduces the letters in another order is an anagram.

Example: catact, study – dusty, gainly – laying etc.,

Logic for anagram is below:

  1. Check for same length
  2. Sort the letters in the given word
  3. Compare the sorted words are same


Leave a Comment

Your email address will not be published. Required fields are marked *