r/coding • • Dec 05 '15

133 Java Interview Questions Answers From Last 6 Years

http://javarevisited.blogspot.com/2015/10/133-java-interview-questions-answers-from-last-5-years.html
110 Upvotes

14 comments sorted by

19

u/rotinom Dec 05 '15

Working for a big tech company, I tend to do a fair number of interviews: 1-2/month

I code in Java nearly exclusively after a decade in C++. I've NEVER asked a single one of these questions. Why? These type of questions are quiz show. They show how well you memorize stuff.

I can find out this stuff after 5 mins on stack overflow. I would trust that anyone I hire can do the same. Therefore the usefulness of these questions are nearly zero.

Show me you can code. Have problem solving skills. Maturity in making decisions. Be self critical. Show me passion. Make me trust that you can kick ass at your job.

3

u/KushDingies Dec 05 '15

I just hope other interviewers have this attitude as well.

3

u/rotinom Dec 05 '15

Yes, at least at the big 4. Analytics and problem solving is a lot harder to teach than language syntax.

If you worked construction, I'd care more about your knowledge of building buildings, than your knowledge of how a particular drill worked.

2

u/Sapiogram Dec 06 '15

Did you even read the article? Sure, some of questions were terrible, but many were great for interviews, and could absolutely not be answered adequately in 5 minutes of googling. Some bad questions are to be expected when there are 120 of them.

1

u/_N_O_P_E_ Dec 06 '15

Can I work for you?

2

u/jppresents Dec 05 '15

Thanks for the interesting read. Here are some possible mistakes I stumbled across:

9: ends with this incomplete sentence: "If you have used Tomcat then when"

19: "if" should be "is"

22: "It is also knowing that clone()" .. should this be maybe "good knowing" to make sence?

36: "which is much smaller than memory memory" .. not sure if this is correct? It reads weird.

39: you skipped the "environment" part of "jre". You could also note, that the jit is part of the jre.

43: "also didn't shared" should probably be "also isn't shared"

48 : ends mid sentence

2

u/jppresents Dec 05 '15

63: "a object" should be "an object" (it's that way in all other answers)

64: double space between "the" and "natural". (there is actually a normal space and a "&nbsp" in the html. weird.)

Java IO (before 66): "alsong with soms" did you mean "along with some"?

76: "waitn" ?

77: "Tell me few" did you mean "a few"?

80: "confort" did you mean "comfort"?

80 b): "exceptions" or "injections"? (actually not sure.. maybe both)

82: too many verbs "does" or "is" not both

1

u/jppresents Dec 05 '15

125: the same as 120

1

u/MachaHack Dec 05 '15

17. BigDecimal isn't needed for most currencies, just use integer cents (or currency equivalent)?

1

u/jamougha Dec 05 '15 edited Dec 05 '15

Integers definitely aren't big enough for many situations. I've seen people specifying values of billions of dollars to within ten-thousandths of a cent, along with a failure because a system was truncating them to 15 significant figures.

Longs are big enough in principle for almost any reasonable range but if you're doing anything involving percentages then you have to worry about rounding modes. Rounding down usually won't be correct. If you're dealing with small percentages applied repeatedly then the difference can become relatively large.

Numbers, especially monetary values are surprisingly hard to get right and there isn't a single simple answer.

1

u/A1kmm Dec 05 '15

19) How do you convert bytes to long in Java?

new DataInputStream(new ByteArrayInputStream(byteArray)).readLong()

1

u/teraflop Dec 05 '15

Shorter:

ByteBuffer.wrap(byteArray).getLong()

Or using [Guava](http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/primitives/Longs.html#fromByteArray(byte[])):

Longs.fromByteArray(byteArray)

1

u/SantiSuarezz Dec 07 '15

Great!!! Thanks a lot for this