r/learnjava • u/ReasonableTwo8 • Jan 12 '21
Java Interview Questions and Answers
Came across this while preparing myself, you can refer to this if you are preparing for Java interview. Hope you find this useful. :)
11
u/vie12345 Jan 12 '21
WTF, I would avoid companies asking such questions.
For my current and last company I did Interviews like 10-15 people who applied last year.
I really prefere having a real conversation instead of one side questioning. I would claim in a slightly controlled conversation I am able to learn more about the understanding then by just asking questions. By just asking I mainly see if he prepared for the questions, memorizing stuff you can look up in like 5 seconds is not an important skill for a software dev.
2
1
u/WinRaRtrailInfinity Jan 12 '21
cool, I will be graduating in a few months so this is a very nice resource. thanks.
1
u/JasburyCS Jan 13 '21
Most of these questions aren’t that bad, in my opinion. I’ve been asked some in interviews. To me it comes down to “is this question assuming they have some trivia memorized? Or can the candidate reason about the answer if they don’t originally know the answer?”
10. How is the creation of a String using new() different from that of a literal?
Unless the candidate specifically has lots of Java experience and is applying for a Java specific role, this is trivia. Not a useful question for knowing how well the candidate can problem solve.
7. Comment on method overloading and overriding by citing relevant examples.
9. Using relevant properties highlight the differences between interfaces and abstract classes.
These are language trivia, but are more reasonable because you should know the answers if you have programmed in Java. They don’t really require memorization. I’ve been asked these in an interview. They are used to show if a candidate actually knows Java if they put it on a resume, and to weed out candidates that list languages that they don’t actually know
5. Although inheritance is a popular OOPs concept, it is less advantageous than composition. Explain.
2. Contiguous memory locations are usually used for storing actual values in an array but not in ArrayList. Explain.
14. Is exceeding the memory limit possible in a program despite having a garbage collector?
These are better questions. I think candidates can reason about the answer even if they don’t know the answer. Make educated guesses. In most cases the interviewer will help you out and you can start a dialogue with them.
13
u/Kolibreeze Jan 12 '21
At least half of these questions are terrible imo, you want to know if people can program and if they can tell you when to use a String vs a StringBuilder, you wouldn't want them to memorize the docs.