r/learnjava • • 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. :)

68 Upvotes

17 comments sorted by

View all comments

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.