<p>When interviewing college coops/interns or recent graduates it helps to have a Java programming question that they can do on a white board in 15 minutes.  Does anyone have examples of good questions like this?  A C++ question I was once asked in an interview was to write a string to integer function which is along the lines of the level of question I am looking for examples of.</p>

[{'answer_id': 53821, 'author': 'Niyaz', 'author_id': 184, 'author_profile': 'https://Stackoverflow.com/users/184', 'pm_score': 3, 'selected': False, 'text': '<ol>\n<li>Write a function to swap variable values using pointers (Really poor ones will fall for this)</li>\n<li>Write a program to find the distance between two points in the XY plane. Make use of a class to store the points.</li>\n<li>Demonstrate the use of polymorphism in java using as simple program.</li>\n<li>Write a program to print the first n prime numbers.</li>\n<li>Write a program to replace a string in a file with another.</li>\n</ol>\n'}, {'answer_id': 53828, 'author': 'David Webb', 'author_id': 3171, 'author_profile': 'https://Stackoverflow.com/users/3171', 'pm_score': 3, 'selected': False, 'text': "<p>Is there any reason why it has to be on a whiteboard?  Personally, I'd rather sit them in front of a keyboard and have them write some code.  Our test used to be a simple 100 (IIRC) line Swing text editor.  We then broke it a few simple ways, some making the code not compile and some a little more subtle, and gave the candidates half and hour and a list of problems to fix.</p>\n\n<p>Even if you can't have them do anything hands on make sure that you do give them some explicitly technical questions.  In another round of interviews there were a surprising number of recent graduates who were  just buzzword-spouting IDE-jockeys, so they could look OKish waving their hands around in front of a whiteboard talking about Enterprise-this and SOA-that, but when given a simple Java fundamentals multiple choice exam asking things about what <code>final</code> and <code>protected</code> meant did horrifyingly badly.</p>\n"}, {'answer_id': 53830, 'author': 'Daren Thomas', 'author_id': 2260, 'author_profile': 'https://Stackoverflow.com/users/2260', 'pm_score': 4, 'selected': True, 'text': '<p>Some stuff that has showed up on SO:</p>\n\n<ul>\n<li>IsPalindrome(string s)</li>\n<li>ReverseWordsInString(string s): "I know java" --> "java know I"</li>\n</ul>\n\n<p>Other stuff that springs to mind:</p>\n\n<ul>\n<li>multiply a Vector with a Matrix (can this be done OO-Style?)</li>\n<li><code>echo</code> (yes, a simple clone of the unix tool)</li>\n<li><code>cat</code> (15 min should be enough, should weed out the clueless)</li>\n<li>a simple container for <code>int</code>s. Like <code>ArrayList</code>. <strong>Bonus question</strong>: Generic?</li>\n</ul>\n'}, {'answer_id': 53847, 'author': 'Nicolas', 'author_id': 1730, 'author_profile': 'https://Stackoverflow.com/users/1730', 'pm_score': 3, 'selected': False, 'text': "<p>I've always thought that algorithmic questions should be language agnostic. If you want to test the java level of a student, focus on the language: its keywords (from common one like static to more exotic one, like volatile), generics, overloading, boxing/unboxing of variable, standard libraries.</p>\n"}, {'answer_id': 53895, 'author': 'rjzii', 'author_id': 1185, 'author_profile': 'https://Stackoverflow.com/users/1185', 'pm_score': 0, 'selected': False, 'text': '<p>I agree with <a href="https://stackoverflow.com/questions/53808/good-15-minute-java-question-to-ask-recent-college-graduate#53847">Nicolas</a> in regards to separating the algorithmic questions from the actual language questions. </p>\n\n<p>One thing that you might want to consider is giving them a couple simple algorithm questions that they can write up the pseudo code for on the white board (ex. "Explain to me the <a href="http://en.wikipedia.org/wiki/Bubble_sort" rel="nofollow noreferrer">Bubble sort</a> and show me the pseudo code for it." </p>\n\n<p>Then once they have demonstrated their algorithmic knowledge you can move on to the Java questions. Since some people work better in front of a computer than in front of the whiteboard, I would give them something simple, but leveraging their knowledge of Java, that they can implement in 30 minutes or so in using the same IDE that you are using at the company. This way if they claim to know the IDE you can also get an idea of how well they know it.</p>\n'}, {'answer_id': 232290, 'author': 'wsorenson', 'author_id': 27579, 'author_profile': 'https://Stackoverflow.com/users/27579', 'pm_score': 0, 'selected': False, 'text': '<ol>\n<li><p>Write a function that merges two sorted lists -- stopping at limit. Look for the easy optimizations and correct boundary checks / sublist calls. Tell them T implements compareTo.</p>\n\n<p>public List&lt;T&gt; merge(List&lt;T&gt; one, List&lt;T&gt; two, int limit)</p></li>\n<li><p>Write a function that returns true if any two integers in the array sum to the given sum. Have them try to do better than n squared using some sort of set or data structure.</p>\n\n<p>public boolean containsSum(int[] nums, int sum)</p></li>\n</ol>\n'}, {'answer_id': 232326, 'author': 'rich', 'author_id': 25502, 'author_profile': 'https://Stackoverflow.com/users/25502', 'pm_score': 0, 'selected': False, 'text': "<p>I would avoid asking them questions that would have been covered in their undergrad classes. I would be more curious about their ability to apply everything they've learned to solve complex technical problems. If your business has a specific need for an IT solution you could use that as a starting point.  You could ask the candidate what technologies they would use and the pros and cons of using those technologies versus alternate technologies.  As the discussion progresses you could get a feel for their technical skills, problem solving skills, interpersonal skills, etc.  I think it is important to avoid coaching them, even in awkward moments.  This is important to weed out the <code>BSers</code>.</p>\n"}, {'answer_id': 1309398, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 1, 'selected': False, 'text': "<p>If you don't know what questions to ask them, then may be you are not the right one to interview them in Java. With all due respect, I hate when people ask me questions in interviews which they themselves don't know answers for. Answers for most of the questions can be found online by googling in a few secs. If someone has experience in Java, they will definitely know Abstract class, interface etc as they are the core building blocks. If he/she does not know 'volatile' keyword - big deal.</p>\n"}]
['https://Stackoverflow.com/questions/53808', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3637/']