aspose file tools*
The moose likes Jobs Discussion and the fly likes Writing programs on interviews Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Careers » Jobs Discussion
Bookmark "Writing programs on interviews" Watch "Writing programs on interviews" New topic
Author

Writing programs on interviews

Louis Smith
Greenhorn

Joined: Apr 14, 2007
Posts: 4
Hello,

I've gone on some java interviews at financial companies, for a senior programming position and they want you to write complete code to solve a problem right on the spot as follows:

Company 1:
A manager gave me a sheet with 5 problems to do in 20 minutes. The first two were simple where a pointer was declared, put not the space it pointed to. You had to see this. Second problem was using ++i vs i ++ on right side of equal sign.

Then there were 3 programs to write:

1. Shift a long ten digits to right.
2. You get an array of sorted integers which repeat, modify the array, so there are no repeats, padding the end with 0's.
3. You have a class:

class Node {
Node next;
};- write a program to reverse a three element linked list, (three of these classes)

Company 2-
Write program to get list of sorted letters and return the letter with the maximum frequency.

For company 1 I received an additinal 20 minutes to try to complete the problems. I was able to do the bit program, though I forgot the shift sign and I had a mental block for problems 2 and 3. I figured them out on the train on the way home without too much trouble, but not under the pressure of the interview. Atleast the manager left the room.

Company 2- I tried an solution with maps, which was way too complicated. Then crumpled up the paper and did a simple solution, which worked ok.
Two programmers were watching me the whole time, not fun. They wanted to know why I didn't check for 0 size array and why I had a case where the index was =0, which was not elegant. It is difficult to do these things in 10 minutes in any fashion,let alone elegantly.

One thing I learned is to have syntax memorized. Also has anyone been
asked to do problems like the ones above on an interview? I would
use them to practice for more interview. Would also like to hear related stories.

Thank you,

Louis
Mike Isano
Ranch Hand

Joined: Jan 19, 2007
Posts: 144
I could make up the most complex problem, give a guy 5 minutes to solve it, (while he is under the stress of an interview) and then easily critique the result. Don't feel bad. The people making the problems have hours to put thought into it, under no pressure.
Louis Smith
Greenhorn

Joined: Apr 14, 2007
Posts: 4
I appreciate Mike's kind words and I wish that I could return the favor of administering quizzes to some of these managers.

Yet I've come across this 2 times out of 3 in NYC and feel that I need to get prepared for this battle of writing complete code on interviews.

Does anyone have any programs that they had to write for an Java interview in person, so I could do some more practice, before I look in books or make up my own?

Thank you,

Louis
arulk pillai
Author
Ranch Hand

Joined: May 31, 2007
Posts: 3220
I had to write a basic multi-threaded program in an interview. Usually they look for how you would go about. ThoughtWorks always get you to write some code and email to them prior to interviewing.


Java Interview Questions and Answers Blog | Amazon.com profile | Java Interview Books
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

Louis,
I administer the programming interview on my team. While I can't give out the questions, I can respond to some of your points and give high level ideas.

Company 1: Was company 1 Java? Their interview questions seem better suited to C++ with mentioning pointers. (Or maybe they meant references). That does sound like a lot to ask in 20 minutes. It also sounds like some of those interview questions came from a book that management read. You could go to the bookstore and get a book about technical/coding interview questions for ideas. A good interview will have their own questions of course. I would never ask a senior person (or anyone more than a year out of school) to do something with linked lists. Mainly because I haven't touched them since college. I want to test knowledge that applies a bit more directly to the job.

I do sit with people and watch while they code. But I have them do it on the computer and allow use of the API/Google. I think this is easier and more realistic. A good developer either knows the stuff by heart or knows where to find it quickly. A poor (or non-Java) developer looks blankly and does random google searches. Either way, this screens out what I want. If someone can't do a simple task on a timely basis, they are likely going to have problems doing the real work.

Company 2: I like this question. The domain is self contained and it shows that you can code/think logically. There are many ways to implement it, so it doesn't pigeonhole the answer. I don't nitpick the results of questions like these. I will ask what happens when the array size is 0. A good developer will tell me and then explain how one could handle it. I do this more for college students to make sure they understand flow. I will do it if an experienced person missed an obvious case. I recognize people are nervous and interviews and understand it is easy to forget some cases. It's more important to know what to do when someone brings it up. While Company 2 made things more stressful than necessary, I think the question itself is sound. Do keep in mind that often developers are thrown into giving interviews. We don't always know how to do it well

> One thing I learned is to have syntax memorized.
Definitely. If you say you know Java, the interviewer is going to test you know Java! I interviewed a person who wrote he had used Java for 5 years on the resume and then wrote:
<br /> So I'm sitting there thinking that maybe he got mixed up with another language that has "end of while". We are in the IDE with a red error message. When he says he is done, I ask if there is anything he wants to change. He says no. When I point at that specifically, he tells me maybe the tool got confused. As an interview, the syntax is a basic building block to everything else.<br /> <br /> > Also has anyone been asked to do problems like the ones above on an
> interview? I would use them to practice for more interview. Would also
> like to hear related stories.
I recommend getting comfortable with practice problems if you haven't been coding full time lately. You can use a university website for examples. A good interviewer isn't trying to trick you, just see if you can use the job and know how to think.

That said, the software companies: Google, Microsoft, etc give more algorithmic issues. It is possible that you interview with someone who worked there and has a different view of tech interviews.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jay Dilla
Ranch Hand

Joined: Aug 12, 2004
Posts: 201
I'm assuming you interviewed for one of the Wall Street financial companies, they tend to have harder interviews because so many people want to work for them. I'd put them right under Google,etc and the top tier companies.

I'm not senior level , more like beginner so I haven't been drilled too much in an interview. They basically just asked me questions that would be in the SCJP test. Like about garbage collection and what is overriding.

Once I did have to have to program and it was pretty simple, they just wanted me to pass a parameter from method or something. But back then I was still in school and didn't even know how to do that.
One of the things that scares me is the thought that I might go to an interview and they ask me to write out JDBC code from scratch or write JSP code from scratch, because I'm so use to either using an IDE or copying and pasting stuff
Louis Smith
Greenhorn

Joined: Apr 14, 2007
Posts: 4
I would first like to thank everyone for all of your helpful responses!

The interview with 5 problems was with a Wall Street firm. Jay hit it on the head.
The second firm told me that they have rejected people who were accepted by Google
and Microsoft.

When Jeanne said that,
"I do sit with people and watch while they code. But I have them do it on the computer
and allow use of the API/Google. I think this is easier and more realistic. A good
developer either knows the stuff by heart or knows where to find it quickly. A poor
(or non-Java) developer looks blankly and does random google searches."

I think this is an enlightened approach to testing and I do alot of coding
searching "sun java (java construct)". Yet since not every interviewer permits this I need to
memorize more syntax. Will also look for academic practice problems. I do a bit of
coding, but need to organize my thoughts quickly if I have limited time (10-30 minutes)to
solve a problem.

It would be scary to have to write a JDBC program from scratch. I would
hope to remember the basic steps and "punt" on some of the syntax. JSP's I
don't know at all.

Thank you again,

LSmith
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Originally posted by Jeanne Boyarsky:
A good developer either knows the stuff by heart or knows where to find it quickly. A poor (or non-Java) developer looks blankly and does random google searches.


Absolutely , only remembering API's would not help in real situation when one needs to know about how to make best use of those.

So , while such interviews are conducted the coder must be given access to API documentation.


Rahul Bhattacharjee
LinkedIn - Blog
Kj Reddy
Ranch Hand

Joined: Sep 20, 2003
Posts: 1704
Compare to olden days now days a programmers no need to remember many things for writing simple or complecated programs because of facilities like IDEs, internet etc., Many people are not comofrtable to write code on paper and they are very comfortable to develop code on system.

If the interviewers ask you to write code to evaluate your logical skills, approach, problem solving skills then it is fine else I am sure they may miss many good candidates.

In one of the interview I was agive problem and I need to write code in either Java or C, C++ to solve the problem. The interviewer doesn't know Java and he knows C, C++. And I am comfortable with Java so I wrote the code in Java using all APIs that comes with Java and that made my job very simple. But the interviewer expected I will write C, C++ kind of code and he didn't communicate that to me and he rejected me. So this kind of evaluation may not be helpful. Also it my mistake not to think why he is given such simple program to write and that time I am not so experienced to think what the interviewer is expecting
[ August 01, 2007: Message edited by: KJ Reddy ]
Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2578

I think asking candidate to write code is definitely a good idea but picking up on syntax is definitely not a good idea. It allows the interviewer to see how candidates proposes solution to a prticular problem with his coding.

Some of the best technical tests/interviews I faced needed me to write code. one of them asked to write code to communicate between an applet & a servlet. They didn't do nit-picking when I wrote ServletRequest instead of HttpServletRequest in my doGet(), doPost() method. They were happy to see request, response parameters.

Another one asked to design some interfcaes for a given problem. I thought both these tests were good.

I often ask a person to write small piece of code to solve a simple problem that I come up with in an interview.

rgds,
- Manish
Theodore Casser
Ranch Hand

Joined: Mar 14, 2001
Posts: 1902

When I read this thread yesterday morning (as I was preparing to take part in an interview for an open position at our firm), I had thought that perhaps it seemed like a little bit of overkill to ask a prospective employee to code on the spot - certainly, I'd never had to do that in any position I'd previously tried for myself. By the time we got out of the interview, I think most of my team was thinking that it might not be a bad idea of a way to see how potential hires think.

Suffice it to say, we're talking this morning about what kind of a simple programming exercise to come up with to give in the future...


Theodore Jonathan Casser
SCJP/SCSNI/SCBCD/SCWCD/SCDJWS/SCMAD/SCEA/MCTS/MCPD... and so many more letters than you can shake a stick at!
v ray
Ranch Hand

Joined: Mar 15, 2007
Posts: 223
Originally posted by KJ Reddy:


In one of the interview I was agive problem and I need to write code in either Java or C, C++ to solve the problem. The interviewer doesn't know Java and he knows C, C++. And I am comfortable with Java so I wrote the code in Java using all APIs that comes with Java and that made my job very simple. But the interviewer expected I will write C, C++ kind of code and he didn't communicate that to me and he rejected me.

Were you told that was the reason you were getting rejected? I would highly doubt if you were rejected for writing a java program. However, if the position for a c++ programmers job, then you are in trouble .
peter cooke
Ranch Hand

Joined: Mar 16, 2004
Posts: 314
for a single 8 hour interview. I had to

Install install tomcat and jboss
configure a connection to db2.

design and implent 3 entity ejbs 1 stateless session, a simple front controller, command classes for add/view/edit/delete, helpers, jsps.


They also wanted junit tests, but there was not enough time. I had also never configured cactus only used it. So I had no way of knowing what or if anything needed to be configured.
[ August 10, 2007: Message edited by: peter cooke ]

CIAO Peter M. Cooke
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

Peter,
I'm a bit wary of an "interview" that has someone doing that much real work. It stinks of free consulting. They should pay you for 8 hours of work. Because that's what it sounds like. Why on earth would the candidate need to install Tomcat and JBoss? Are they saying that is a major part of your job?
Mike Mc Afee
Greenhorn

Joined: Jan 31, 2007
Posts: 19
Does anyone have any programs that they had to write for an Java interview in person, so I could do some more practice, before I look in books or make up my own?


I found this book to be helpful in interviewing for the job I have
[ August 10, 2007: Message edited by: Mike Mc Afee ]
Jay Dilla
Ranch Hand

Joined: Aug 12, 2004
Posts: 201
Originally posted by Mike Mc Afee:


I found this book to be helpful in interviewing for the job I have

[ August 10, 2007: Message edited by: Mike Mc Afee ]


I have this book, haven't gotten around to reading it tho.
peter cooke
Ranch Hand

Joined: Mar 16, 2004
Posts: 314
They paid me for 8 hours of work.

Since I completed 90% of what they wanted they offered me the job. I turned them down because I was offered another job that had 1/2 the commute time.

when we discussed the brass tacks at salery negotions. A portion of my time would be setting up and deploy apps (prototype, customer acceptance, production apps on customers computers.)
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

Originally posted by peter cooke:
They paid me for 8 hours of work. ... A portion of my time would be setting up and deploy apps (prototype, customer acceptance, production apps on customers computers.)

That sounds better. They paid you and it was relevant. Almost like test the new hire for a one day trial before making an offer. That's perfectly respectable. I couldn't do it for security reasons (I work for a bank), but in my mind it is a great technique.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Writing programs on interviews