Home     Java   Linux    Jobs    Advertise    Book Reviews    Write for Us     Blog
Java Interview Questions

Java Interview Test Questions


I was talking to a colleague last week and our discussion moved to various topics, and one of those topics was the type of test that some programmers have to sit during a job interview. We have all sat different tests during our job hunting days, and some of those practical tests were good. I mean, it helps to keep both the applicant and the employer on their guard against cowboy programmers. I would encourage every potential employer to ensure they have areas and topics they would expect every new employee to know inside out.

He told me that one of the questions or test he had to sit was to write the Fizz Buzz program. Ironically enough, I was once asked to write the same program by a Dutch company a couple of years when I was job hunting, and it took me less than 5 minutes to do. Then the prospect of moving away from the UK at that time was exciting and I was looking to go to Holland and work there, but after the interview, I had a change of heart and thought it was a very bad idea to go to Holland to work when I could get lots of jobs closer home.

So, here is a sample solution for anyone to have a look and study, you never know you could be asked to write the same thing next time you go for a job interview.

The file itself can be downloaded here.

Please note: this is a Java version of the popular Fizz Buzz problem, but I hope to post the same solution in other languages too. But if you've written one and would like to share yours with the community, please it to me and I will add it here for others to use.


/**
 * This simple program takes a single positive integer from standard in and prints every 
 * number in sequence up to that number. For every number that is 
 * divisible by 3 it prints fizz instead, For every number that is divisible
 * by 5 it prints buzz instead and for numbers divisible by both print fizz buzz.
 *
 * @Date 19-July-2003
 * @Version 0.1
 @author Evans Anyokwu 
 */

 
public class FizzBuzzLoop
{
    public static void main (String[] args)
    {
        System.out.print ("Enter a positive Integer number e.g 50:");
        java.io.DataInputStream keyboard = new  java.io.DataInputStream (System.in);
        int valueEntered = 0;

        System.out.flush ();
        try{
            valueEntered = Integer.valueOf (keyboard.readLine().trim()).intValue ();
            for (int i = ; i <= valueEntered; i++){
                if (i % == 0){
                    System.out.print ("fizz ");
                }
                if (i % == 0){
                    System.out.print ("buzz");
                }
                
                if (!((i % == 0|| (i % == 0)))
                    System.out.print (i);
                System.out.println ();
            }            
        }

        catch (java.lang.Exception exception){
            
           System.out.println ("Please try again and enter a positive Integer");
        }//end try/catch
    }//end main
}//end class

Which Interview Books to Buy?

The short answer is: there's no book to buy, all you need is to be yourself. Its very important that one prepares very well before an interview. There's nothing more surprising to see people go for a job interview and not prepared. The least you can do is to go through your CV and the job specification on your way to the interview and try as much as possible to remember all those details you have on your CV.

Most interviews start from the top down on your CV and work their way down. While others start from the bottom, this can be confusing at times, so make sure you know what you have on your CV and the dates of your education and training.

Don't get me wrong, there are times when I can positively recommend a book or resource based on the area or domain that you are interested in. For example, I'm currently reading the Definitive Guide to SQLite, to write my first database app, you might want to pick up wxPython in Action if you're going to start writing wxPython GUIs; or Python & XML if you're doing XML work; etc. The reason for this exception is to help you to narrow you search and effort to a domain-specific area. Apart from that, I will not recommend any book as we all learn differently.

IDE

Another question that we come across often is which IDE is the best to use. Again, there are no right answers here. If you are on windows and you downloaded your Python installation from Python.org, then you do not need any other IDE as it installs IDLE by default. This is the official IDE that most guys on the mailing list probably use on their Windows environment. Having said that, other 3rd-parties also produce their own IDEs. A typical example is Pythonwin from ActiveStates' ActivePython distribution (which is not open source).

The list of all available IDEs can be found here is you are more interested on learning about the IDEs than the language.

Finally, I have decided to list the books here to help you with your quest for that killer Python book :-) One of those excellent online books is this, it contains all the information that a new Python programmer will find very useful.

But if you have a few quid and you want something you could have on your bookshelf, here are my recommendations:

1) Programming Python by Lutz
2) Dive into Python (available online)
3) Python Cook Book (common recipes)
Core Python Programming (2006, 2 copies)
Game Programming with Python (2004)
Programming Python (2006, 2 copies)
Python Cookbook (2005, 2 copies)
Python Essential reference (2006, 2 copies)
Python in a Nutshell (2006, 2 copies)
Python Phrasebook (2006, 2 copies)
Python programming for the absolute beginner (2003)
Python programming on Win32 (2000)
Rapid web appplications with TurboGears (2006, 2 copies)
Sams teach yourself Python in 24 hours (2000)
Twisted network programming essentials (2005)
Twisted network programming essentials (2006, 2 copies)

Click here for cheap Python Book


Find out more about Me.


Java Resources

Java Sockets
J2ME
XML
Web Services
The Secret