If you’re looking for a job in software development or any other role that is highly technical, chances are you will be asked to participate in a technical interview. In this interview you’ll be given questions that test your technical subject-matter knowledge and ability to apply your skills. You can learn all about technical interviews and how to prepare for them from our Guide to Acing the Technical Interview.
Some technical interviews are generic and ask a wide range of programming questions, but interviews for more specific roles may focus on a single language, like Java. Here we’ve compiled a list of technical interview questions you may be asked in a Java interview. To learn more about Java and its applications, check out our ultimate guide to Java.
1. Explain the difference between member variables, local variables, and loop variables.
2. Explain what makes Java “platform-independent.”
3. Explain each of the following:
4. Explain what a private method is and give an example.
5. Explain the “super” keyword.
6. Explain the following data types with examples:
7. What are static methods and static variables?
8. Explain the difference between an Array and an Array List.
9. What syntax is used to define a class in Java? Give an example.
10. What is a servlet?
11. Can you explain the steps in a servlet lifecycle?
12. What are the two ways to create a “thread”?
13. What are some situations where you could use the “this” keyword?
14. Explain encapsulation. Why is it useful?
15. What is a nested class?
16. What causes a compiler error in the following program?
17. Given an array of N integers, write a program to find the contiguous sub-array (containing at least one number) with the maximum sum. The program should return this sum.
18. Write a program that takes a given binary tree and produces the tree’s mirror as an output. As in the image below:
19. Write a program that, given an Array of N positive integers, finds the K largest element.
20. Write a program that checks whether two strings a and b are an anagram of each other or not. A pair of anagrams are two words that contain all of the same letters but in different orders.
The following sites are excellent resources to use to continue prepping for a Java interview.
LeetCode is an awesome one-stop shop for technical interview prep. They have a large database of questions for technical interviews. The coolest feature on LeetCode is that they allow you to choose from a dropdown of languages when solving a problem. You can try answering in C++ first and then give the same question a shot in Java to see which way is cleaner. They also offer guided study plans and forums where other job hunters can post about their technical interview experiences.
InterviewBit has a robust collection of practice questions for Java and other subjects. They also have useful guides to the interview processes at prominent tech companies like Google, Adobe, and Amazon.
Geeks for Geeks offers a collection of technical practice problems and theoretical problems. In their Practice section you can sort questions by company to narrow your preparation for a specific interview at Google, Amazon, or elsewhere.
Interview Cake sells an interview prep course for $100 to $200. However, they also offer an abbreviated free course as well as free interview tips and review materials.
To find coding bootcamps that cover Java in their curriculums, check out our Java overview page. If you’re ready to start applying for Java jobs now, review out our Guide to Writing a Technical Resume to start creating your application materials. To learn more about technical interviews in general – what to expect, study tips, and more – read through our Guide to Acing the Technical Interview.
Best of luck on the job hunt!