473,839 Members | 1,509 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Java Interview Questions: Am I Being Too Difficult?

I've been tasked with doing technical interviews at my company,
and I have generally ask a range of OO, Java, and "good programming
technique" concepts.

However, one of my favorite exercises I give interviewees seems
to trip them up all the time, and I wonder if I'm being too much
of a hardass... it seems easy enough to ME, but these guys, when
I get them up to the whiteboard, seem to get really confused.

The exercise is this:

Create one or more classes that represent a binary tree.

This class(es) must be able to do standard sorts of operations
one would do on a binary tree in a good, OO sort of way.

A node in this tree holds only a single, String, value.

Now write for me a method named 'find' that takes an argument
of a String (or a String and a Node, depending upon your
implementation) and returns a java.util.List of all nodes,
from the node it's called upon and all descendent nodes, inclusive,
who's value matches that of the String argument.

The code must be syntactically correct, and would compile.

As an added exercise, how would you make this code thread-safe?

Seems pretty simple, huh? But most guys we've brought in just sit there
staring at the board, and have trouble even writing the basic
Node class... they get all confused, don't know how to traverse a
tree, etc.

Am I unreasonable in expecting someone to be able to do this???

- Tim

--

Jul 17 '05
54 17459
kaeli wrote:
Fun stuff. *g*


If you don't already know it, you might enjoy:

<http://www.ocf.berkele y.edu/~wwu/riddles/intro.shtml>

-- chris (that's *this* chris, not *that* Chris)
Jul 17 '05 #21
In article <SI************ ********@nildra m.net>,
ch*********@met agnostic.REMOVE-THIS.org enlightened us with...
kaeli wrote:
Fun stuff. *g*


If you don't already know it, you might enjoy:

<http://www.ocf.berkele y.edu/~wwu/riddles/intro.shtml>

-- chris (that's *this* chris, not *that* Chris)


Ooh, I like these sorts of things. I get kind of bored just doing web
apps all the time. It doesn't take much thought process for most of it.
Once you develop the back end, the front end rather builds itself.

Thanks for the link.

--
--
~kaeli~
Kill one man and you are a murderer. Kill millions and you
are a conqueror. Kill everyone and you are God.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 17 '05 #22
Spammay Blockay wrote:
In article <Yc************ ******@newsread 2.news.atl.eart hlink.net>,
Dan Nuttle <d_******@hotma il.com> wrote:
My personal opinion about interview questions is that they should be
designed to indicate whether the person being interviewed can be a valuable
member of your team. So the only relevant criterion to be applied to any
given question is, does it help to indicate whether the person being
interviewed can be a valuable member of your team?

Well, I can see your point... the thing is, I guess I have
some pretty strong ideas about what "good programmers" *should*
be able to do, and the kinds of things they should know.
Basically, they should:

1) Have a broad knowledge of common data structures, how
they work, and how they are implemented (and be able to
implement them themselves, even if perfectly good, complete
implementations exist in easily-found libraries).


The question you ask, though, is "Demonstrat e knowledge of
data structure X." Perhaps a better question might be "Tell me
all about your favorite data structure, and sketch an implementation. "
Less coercive, more open-ended -- and you might even learn a thing
or two ...
2) Have experience in all tiers of common sorts of applications
(UI, Business Logic/Middleware, Database, Network)
The binary tree exercise doesn't test this, or not very much
at any rate. Again, I'd put the onus on the interviewee: "Tell me
about some Topic X work you've done. What problems did you encounter?
How did you solve them? What would you do differently if you were
to do the whole thing over again?"
3) Be able to quickly come up with relatively clever algorithms
that solve common (or uncommon) sorts of problems.
A highly structured question about binary trees doesn't seem
to give a lot of scope for cleverness. Also, I question whether
"clever" is an unadulterated Good Thing.
4) Be very comfortable with most uses of boolean logic,
as they appear in programming environments (eg. the
ability to code complex if/then/else's and not lose
track of the logic they're trying to code)
Your question might test this ability, but I think lightly.
There's not a lot of "complex if/then/else's" in most of the
methods I'd imagine for a binary tree implementation.
5) Know that it is important to make your code readable,
clear, and concise
Notice the clash between "clear" and "clever," a few paragraphs
back. Notice, too, the clash between "clear" and "complex" in the
preceding paragraph. These clashes are not unresolvable, but it
requires some discipline on your part to remain open to trade-offs
that you yourself would have made differently.
6) Be able to quickly write code that accomplishes simple tasks
(eg. write a Java Bean, write a Comparator, know how to use
the Java Collections API, etc.).
Your question seems a reasonable test of this one. The test is
superficial, of course, but you probably can't have the interview
drag on for six weeks ;-)
In the interview I had today with this guy, he knew what a Binary Tree
was. But then he started coding it as an N-ery tree, with an add(Node myNode)
method. That's not a binary tree. So I clarified it for him "In a binary
tree each node may have at most two child nodes, left and right".
There's really no essential difference between a binary tree
and a forest of general ordered trees. See Knuth, Volume 1.
He continued working, but very slowly, not seeming to understand
what the first thing he might want to do would be.

He showed some knowledge of how to approach the problem (wrote a BTree
interface, then applied it to a class), but didn't seem comfortable
just diving right in and getting his hands dirty, which is what we DO
need for this position. [...]
But isn't knowing what a binary tree is, and how to code one,
something that's kind of Computer Science 101-ish?


Dunno, as I myself never had the benefit of any CS classes.
(I've taught 'em, but never took one.) Trees are pretty basic,
though. In my own development, trees were the third data structure
I ran into (after arrays and linked lists, and before hash tables).
And Knuth describes them in Volume 1, not in Volume 42 ... I'd
tend to view with some suspicion a programmer who didn't grasp
trees well -- but on the other hand, a programmer who spends his
days dreaming up ways to solve non-linear partial differential
equations in twelve dimensions might be more than a little rusty
on data structures but be a whiz-bang programmer nonetheless. It
all depends on what you (think you) need.

--
Er*********@sun .com

Jul 17 '05 #23
kaeli wrote:
Ooh, I like these sorts of things. I get kind of bored just doing web
apps all the time. It doesn't take much thought process for most of it.
Once you develop the back end, the front end rather builds itself.


For more interesting programming problems, I find
http://www.topcoder.com to be rather amusing.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Jul 17 '05 #24
Liz

"Eric Sosman" <Er*********@su n.com> wrote in message
news:40******** ******@sun.com. ..
Spammay Blockay wrote:
In article <Yc************ ******@newsread 2.news.atl.eart hlink.net>,
Dan Nuttle <d_******@hotma il.com> wrote:
My personal opinion about interview questions is that they should be
designed to indicate whether the person being interviewed can be a valuablemember of your team. So the only relevant criterion to be applied to anygiven question is, does it help to indicate whether the person being
interviewed can be a valuable member of your team?

Well, I can see your point... the thing is, I guess I have
some pretty strong ideas about what "good programmers" *should*
be able to do, and the kinds of things they should know.
Basically, they should:

1) Have a broad knowledge of common data structures, how
they work, and how they are implemented (and be able to
implement them themselves, even if perfectly good, complete
implementations exist in easily-found libraries).


The question you ask, though, is "Demonstrat e knowledge of
data structure X." Perhaps a better question might be "Tell me
all about your favorite data structure, and sketch an implementation. "


A doubly linked list that uses only one pointer. Knuth vol 1.
Less coercive, more open-ended -- and you might even learn a thing
or two ...
2) Have experience in all tiers of common sorts of applications
(UI, Business Logic/Middleware, Database, Network)


The binary tree exercise doesn't test this, or not very much
at any rate. Again, I'd put the onus on the interviewee: "Tell me
about some Topic X work you've done. What problems did you encounter?
How did you solve them? What would you do differently if you were
to do the whole thing over again?"
3) Be able to quickly come up with relatively clever algorithms
that solve common (or uncommon) sorts of problems.


A highly structured question about binary trees doesn't seem
to give a lot of scope for cleverness. Also, I question whether
"clever" is an unadulterated Good Thing.
4) Be very comfortable with most uses of boolean logic,
as they appear in programming environments (eg. the
ability to code complex if/then/else's and not lose
track of the logic they're trying to code)


Your question might test this ability, but I think lightly.
There's not a lot of "complex if/then/else's" in most of the
methods I'd imagine for a binary tree implementation.
5) Know that it is important to make your code readable,
clear, and concise


Notice the clash between "clear" and "clever," a few paragraphs
back. Notice, too, the clash between "clear" and "complex" in the
preceding paragraph. These clashes are not unresolvable, but it
requires some discipline on your part to remain open to trade-offs
that you yourself would have made differently.
6) Be able to quickly write code that accomplishes simple tasks
(eg. write a Java Bean, write a Comparator, know how to use
the Java Collections API, etc.).


Your question seems a reasonable test of this one. The test is
superficial, of course, but you probably can't have the interview
drag on for six weeks ;-)
In the interview I had today with this guy, he knew what a Binary Tree
was. But then he started coding it as an N-ery tree, with an add(Node myNode) method. That's not a binary tree. So I clarified it for him "In a binary tree each node may have at most two child nodes, left and right".


There's really no essential difference between a binary tree
and a forest of general ordered trees. See Knuth, Volume 1.
He continued working, but very slowly, not seeming to understand
what the first thing he might want to do would be.

He showed some knowledge of how to approach the problem (wrote a BTree
interface, then applied it to a class), but didn't seem comfortable
just diving right in and getting his hands dirty, which is what we DO
need for this position.

> [...]
But isn't knowing what a binary tree is, and how to code one,
something that's kind of Computer Science 101-ish?


Dunno, as I myself never had the benefit of any CS classes.
(I've taught 'em, but never took one.) Trees are pretty basic,
though. In my own development, trees were the third data structure
I ran into (after arrays and linked lists, and before hash tables).
And Knuth describes them in Volume 1, not in Volume 42 ... I'd
tend to view with some suspicion a programmer who didn't grasp
trees well -- but on the other hand, a programmer who spends his
days dreaming up ways to solve non-linear partial differential
equations in twelve dimensions might be more than a little rusty
on data structures but be a whiz-bang programmer nonetheless. It
all depends on what you (think you) need.

--
Er*********@sun .com

Jul 17 '05 #25
Liz wrote:
"Eric Sosman" <Er*********@su n.com> wrote in message
news:40******** ******@sun.com. ..

The question you ask, though, is "Demonstrat e knowledge of
data structure X." Perhaps a better question might be "Tell me
all about your favorite data structure, and sketch an implementation. "

A doubly linked list that uses only one pointer. Knuth vol 1.


If you're referring to the XOR trick, I think this would be
a risky choice because of the "sketch an implementation" piece.
As an interviewer, I'd be all over you about how you're going
to swizzle a Java reference variable ...

THEN if you pointed out that links need not be references,
and sketched an implementation using array indices in an arena
consisting of a LinkedListNode[], I'd have confidence that you
knew whereof you spoke.

Of course, if you were to choose something too simple ("My
favorite data structure is the free-standing `int' variable"),
I'd exercise my interviewer's prerogative and request another
nominee ;-)

The important thing, I think, is to avoid trying to assess
someone's ability based on a small "hit list" of pre-selected
topics. That's why I prefer to let the interviewee come up with
the knowledge to be demonstrated: not "Do you know X?" but "Tell
me something you know." I'm usually able to ask enough awkward
questions to separate those who actually do know from the mere
parrots. So far, anyhow ...

--
Er*********@sun .com

Jul 17 '05 #26
SP*********@BLO CKEDTOAVOIDSPAM .com (Spammay Blockay) wrote in message news:<c8******* ***@bolt.sonic. net>...
I've been tasked with doing technical interviews at my company,
and I have generally ask a range of OO, Java, and "good programming
technique" concepts.

However, one of my favorite exercises I give interviewees seems
to trip them up all the time, and I wonder if I'm being too much
of a hardass... it seems easy enough to ME, but these guys, when
I get them up to the whiteboard, seem to get really confused.

The exercise is this:

Create one or more classes that represent a binary tree.

This class(es) must be able to do standard sorts of operations
one would do on a binary tree in a good, OO sort of way.

A node in this tree holds only a single, String, value.

Now write for me a method named 'find' that takes an argument
of a String (or a String and a Node, depending upon your
implementation) and returns a java.util.List of all nodes,
from the node it's called upon and all descendent nodes, inclusive,
who's value matches that of the String argument.

The code must be syntactically correct, and would compile.

As an added exercise, how would you make this code thread-safe?

Seems pretty simple, huh? But most guys we've brought in just sit there
staring at the board, and have trouble even writing the basic
Node class... they get all confused, don't know how to traverse a
tree, etc.

Am I unreasonable in expecting someone to be able to do this???

In a work enviornment no, in a uni assignment no but in an interview ?
- Tim

--

Hi Tim,

I've done heaps of interviews so I share your pain. I also found most
didn't understand the basics.

Mind you my basics were even more basic than yours. I just had a base
class, a derived classed and a polymorphic show() ... and we just
talked through various things.

Questions like how would you do this, why would you do that... when to
use inheritence vs containment. What do you think is important?
Why/why not?

I focused on depth of understanding, experience, design, their ability
to reason and make intelligent tradeoffs ... I didn't care about
syntax errors, compilers easily catches those.

So I agree, tests are a great idea.

But on OTOH personally I wouldn't test using a BinaryTree.

I have 19 years experience, all my performance reviews have been
excellent, my solutions just keep on running, I've done really well at
uni and in the field, I've implemented way too many BinaryTrees in C,
Pascal, C++ (none in Java I use TreeMap/TreeSet) ... yet I would
probably fail your BinaryTree test!

Not that I don't know BinaryTree's but an interview environment is
radically different to a work enviornment. It makes people nervous. It
would take me by surprise, I'd have to context-switch and that takes
time.

But put a keyboard under my fingers and I'll thump a BT out no
problem. Let me use my references or my past code and it's all so
easy!

But would I recall it all in an interview on a whiteboard? NO.

It's a dilicate matter of balance. Interviews ain't easy, I do
sympathize with you ;-|

OTOH not all get nervous some really shine in interviews yet they
can't program for peanuts! They present extremely well, they've got
all the lingo down, design patterns, OO-speak, buzz words, charm
galore but ... they can't program!

Another big factor are they burnt out? They may really need a big
holiday and not a new job.

Tim, above all the most important thing for me is
how-well-would-they-get-on-with-everyone?

I've worked with very clever guys but some were savages to get on
with, I hated it. I'm considered by most as easy going, I don't want
to have wars at work! Nightmares about work at home.

....
Some ideas: Maybe an 80% completed BinaryTree, they could talk about
what's missing ... or a poorly designed tree and they can suggest how
to make it good. Oh I dunno ...

Best wishes ;-)
Alex
Jul 17 '05 #27
I believe it was Gawnsoft who said...

Test for /ability to pick up new stuff/.

Currently your test does not test for this. It primarily tests for
existing knowledge of tree structures.


In other words, he's acting like most companies hiring programmers,
they are looking for people who know how problems were solved rather
than people who can solve problems.
Jul 17 '05 #28
Sam
"Chris Uppal" <ch*********@me tagnostic.REMOV E-THIS.org> wrote in message news:<j4******* *************@n ildram.net>...
Chris Smith wrote:
An example of how few programmers can pass a "simple" test -- at least
in an interview situation. [...]


Wow. The last time I interviewed for a job (about three years ago, and
it wasn't even a programming job!) I was asked a much harder question
than that to solve at a whiteboard in the middle of an interview. The
problem was something like "Given an array of integers of length m, and
a target integer n, write an O(m)-time algorithm to find two array
elements whose sum is n."


Ouch. Or maybe not, it depends on the interview situation. It's a nice little
problem for someone sitting happily at home with a glass of wine. But not a
challenge I'd relish in an adversarial interview situation. In a more
friendly, chatty, interview where I felt I could think out loud, and get
"credit" for exploring avenues that turned out to be dead ends, then it'd be a
lot more fun (and, presumably, a lot more informative for the interviewer).
If what you're saying is true, I wonder how many correct answers they
got to *that* question.

might bring out the best in some people. Maybe we (at the shop I
mentioned) would have got more information about candidates if we'd split the
challenge(s) up, but made them harder.

Step 1: introduce some abstract problem that you hope the candidate can solve
with some thought and discussion.

Step 2: /then/ challenge them to turn their solution into approximately
workable code.

Thinking about it, it seems to me that a "difficult" algorithmic question like
that
At least it could avoid the mental log-jam caused by trying to work out what
the code should do at the same time as actually writing it.

-- chris


Agree completely. Interviews should focus on the candidates ability to
develop solutions to a problem in the context of discussion between
professionals. For example, I very much enjoy bouncing ideas off of a
colleague, and letting the chemistry take hold. This is more effective
than ivory-tower, genius programming for a variety reasons, such as:

1) Creates social interaction and a sense of shared goals.
2) Reduces isolation in an inherently anti-social profession.
3) Speeds up the development process by allowing ideas and solutions
to stew to the surface more quickly than the "lone genius" appoach.
4) Allows project personal to know very precicesly what you're working
on, where you're at, and how you're progressing, thus obviating the
intrusive and often demoralizing status reporting so favored by
un-enlightened managers.
5) Sharing information not only generates solutions, but spreads
knowledge which can be used later for the "general good".

My belief is that someone who is stubborn, arrogant, egotistical,
argumentative, etc., regardless of skill level, is usually usually a
major detriment to a project. Otoh, (and this is rare), someone who
knows how to listen, is flexible and supple in thier thinking, who has
a good feel for the "critical path", a willingness, even a desire to
explore and learn new stuff, has a strong record of delivering "rocks"
and involvement in succesfull projects, and who has demonstrated and
ability to think "out of the box", is someone whose candidacy should
be strongly considered.

Computing is by definition a creative and ongoing learning process.
Tying a candidate's success or lack thereof to his or her ability to
produce some code relating to a technique he may not be familiar with
while under the pressure of an interview is not only rather silly, but
is probably depriving the company of some very capable employees.

Regards,
Sam Hunt
Jul 17 '05 #29
Eric Sosman wrote:
The question you ask, though, is "Demonstrat e knowledge of
data structure X." Perhaps a better question might be "Tell me
all about your favorite data structure, and sketch an implementation. "
Less coercive, more open-ended -- and you might even learn a thing
or two ...


Eric,

I get your point here, but I'm just imagining being in an interview and
being asked that question. I suppose I'd feel very awkward and wonder
what kind of an answer is desired. "Well, I've always felt a special
bond of friendship with the red-black tree..."

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Jul 17 '05 #30

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3499
by: abcd | last post by:
kutthaense Secretary Djetvedehald H. Rumsfeld legai predicted eventual vicmadhlary in Iraq mariyu Afghmadhlaistmadhla, kaani jetvedehly after "a ljetvedehg, hard slog," mariyu vede legai pressed Pentagjetvedeh karuvificials madhla reachathe strategy in karkun campaign deshatinst terrorism. "mudivae maretu winning or losing karkun global varti jetvedeh terror?" Mr. Rumsfeld adugued in a recent memormariyuum. vede velli jetvedeh madhla...
0
6172
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of attending interviews. If you own a company best way to judge if the candidate is worth of it. http://www.questpond.com/InterviewRatingSheet.zip 2000 Interview questions of .NET , JAVA and SQL Server Interview questions (worth downloading it)
2
6978
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of attending interviews. If you own a company best way to judge if the candidate is worth of it. http://www.questpond.com/InterviewRatingSheet.zip
2
7230
by: freepdfforjobs | last post by:
Full eBook with 4000 C#, JAVA,.NET and SQL Server Interview questions http://www.questpond.com/SampleInterviewQuestionBook.zip Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of attending interviews. If you own a company best way to judge if the candidate is worth of it. http://www.questpond.com/InterviewRatingSheet.zip
0
10906
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10585
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10647
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10292
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9426
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7828
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5682
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5866
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4064
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.