Before starting your job search, look at these common Java interview questions asked during real interviews and understand the answers, but instead of memorizing the answers try to complete further research and come with your own personal solution for the interview question. The more prepared you are for what you will encounter, the more successful you will be. This collection of Java interview question could be also useful for software developers who need to interview Java developer.

Java interview question: Fibonacci Numbers

Assessing Java Developer technical skill level is a quite difficult thing when interviewer only has limited time. The solution would be to give a candidate a chance to demonstrate Java development experience by coding problem that requires writing a short, straightforward function. The ideal interview questions for interviewing not only Java Developer with 2 years of experience, but any Java Developer would be implementation of function which returns the n-th number in Fibonacci numbers with an input n.

Fibonacci numbers are defined as:

Java interview question: Fibonacci Numbers

There are two ways to develop Fibonacci sequence function: recursion or iteration. Here is the solution with recursion which return first 12 Fibonacci numbers. I strongly believe that a slow candidate should be able to produce an answer in five minutes or less.

 static long Fibonacci (int n) {
       return n == 0 ? 0 : (n == 1 ? 1 : (Fibonacci (n - 1) + Fibonacci(n - 2)));
 }

 public static void main ( String[] args ) {
       for ( int f = 0; f < 12; f++ ) {
           System.out.print ( Fibonacci (f) + ", " );
       }
       System.out.println ( Fibonacci (12) );
   }

What if some Senior Java Developer with 10 years of experience refuses to code Fibonacci Series explaining that it is not a question that implies on any practical experience and can be easily memorized. In this case you have no choice and ask the candidate one more time or add the candidate to do not no hire list. Do you really want to work with developer, who will tell you from time to time that assigned problems are below developer's skill and experience.

No comments: