CodingInterview
Java solutions to common coding interview questions
Java
- What happens when you remove the keword
static
from a Java main method? If there is an error, do you see it at compile time or run time? (Answer) - What are the key differences between an
ArrayList
and aLinkedList
? When would you choose to use one over the other? - What is a
HashSet
? How does it work? - What happens when two objects inserted into a
HashMap
have the same key? - Are
ArrayList
operations thread safe? - What are some of common issues with multi-threaded applications? How do you mitigate these issues?
- When should you implement
equals
andhashCode
methods in a Java class? - What's the difference between a class and an interface?
- What is an abstract class?
- What are the uses of the
static
keyword? - What are the uses of the
final
keyword? - What is the difference between method overloading and method overriding.
- What data type would you use to represent currency? What are the drawbacks of using other types?
- What data structure can you use if you need to look up objects by a key and you want to iterate through them in order?
- Explain how you would implement a
HashMap
. What methods would it have? How would it store data internally? - What is autoboxing?
- What does the
finalize
method do? When would you override it?
Servlets & JSP
- What is the difference between the
doget
anddoPost
methods? - Explain the JSP lifecycle.
Object-oriented Programming
- What are the "three pillars" of object-oriented programming?
- Explain inheritance and polymorphism. How are they related?
- What does it mean to "program to an interface"?
- What are the SOLID principles?
Design Patterns
- What is the Singleton design pattern and when would you use it? Describe how you would implement a Singleton class.
- Describe how the Observer design pattern is implemented.
- What is the Facade design pattern?
- What is the Delegate design pattern?
SQL
- What are the different types of joins? When do you use each type?
- What are aggregate functions in SQL? How do you use them?
Unit Testing
- How do you create a test suite in JUnit?
- How can you prevent a test from running when you run a test suite?
Miscellaneous
- What are some advantages of continuous integration?
- In Hibernate, what is the n+1 problem?
- What are the steps you would follow when investigating a performance issue?