vimal4david / Top50InterviewQuestions

Solutions for top 50 Java interview questions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Top 50 Interview Questions

Solutions for top 50 Java interview questions.

Question 1 (FizzBuzz)

Write a short program that prints each number from 1 to 100 on a new line.For each multiple of 3, print "Fizz" instead of the number.For each multiple of 5, print "Buzz" instead of the number.For numbers which are multiples of both 3 and 5, print "FizzBuzz" instead of the number.

Question 2 (Fibonacci numbers)

Write a program to calculate and print Fibonacci number using both recursion and Iteration.

  • Fibonacci number is sum of previous two Fibonacci numbers fn= fn-1+ fn-2
  • First 10 Fibonacci numbers are 1, 1, 2, 3, 5, 8, 13, 21, 34, 55

Question 3 (Reverse a string)

Write a program to reverse a string since there is no utility method in the String class.

  • For e.g reverse of string "happy" is "yppah"

Question 4 (Prime Number)

Write a Java program to check if a given number is prime or not. Remember, a prime number is a number which is not divisible by any other number, e.g. 3, 5, 7, 11, 13, 17, etc. Be prepared for cross, e.g. checking till the square root of a number, etc.

About

Solutions for top 50 Java interview questions


Languages

Language:HTML 98.4%Language:Java 1.6%