Explain core Java and Spring fundamentals
AntraSoftware Engineer · Technical ScreenLast updated
This question evaluates core competencies in Java and Spring, covering data structures and collections, object-oriented design (SOLID), hash-based collections and concurrency primitives, immutability and string handling, exception handling, Spring IoC/DI and AOP, bean lifecycle and annotations, and functional collection processing via the Stream API. Commonly asked in Software Engineering Fundamentals interviews for backend Java/Spring roles, it checks both conceptual understanding and practical application by assessing architectural reasoning, concurrency and thread-safety knowledge, and familiarity with framework conventions and APIs.
Java and Spring fundamentals
You are interviewing for a backend Java/Spring role. Answer the following conceptual questions:
- Collections & data structures
- Compare
ArrayListandLinkedListin Java in terms of internal implementation, time complexity for common operations (access, insertion, deletion), and typical use cases.
- Object-oriented design
- Explain the SOLID design principles and give a short example for each principle.
- Hash-based collections & concurrency
- Compare
HashtableandHashSet: what does each store, how are keys/values handled, and what about thread safety? - Explain what
ConcurrentHashMapis, how it differs fromHashMapandHashtable, and in what situations you would use it.
- Strings and immutability
- Compare
String,StringBuilder, andStringBufferin Java, including mutability and thread safety, and when you would use each. - What does it mean for an object to be immutable? Why can immutability be useful?
- Describe how you would design and implement an immutable class in Java.
- Concurrency primitives
- Explain the purpose and behavior of the
volatilekeyword in Java. What problems does it solve and what are its limitations? - Explain what synchronization (the
synchronizedkeyword) does in Java. How does it provide thread safety and what are the trade-offs? - Describe the
java.util.concurrent.atomicpackage: what problem does it solve, and how do classes likeAtomicIntegerandAtomicReferencework conceptually?
- Exception handling
- How should exceptions be handled in Java? Explain checked vs unchecked exceptions and discuss best practices for exception handling in real applications.
- Spring core concepts
- Explain Inversion of Control (IoC) and Dependency Injection (DI) in the context of the Spring framework, with an example of how dependencies are wired.
- Explain Aspect-Oriented Programming (AOP) in Spring and give common use cases (for example, logging, transactions).
- Describe how to define and use beans in Spring (for example, via annotations, Java configuration, or XML). How are beans created, managed, and injected?
- Compare the stereotype annotations
@Component,@Service, and@Repositoryin Spring. What do they have in common and when would you use each? - What other common Spring annotations do you know (such as
@Controller,@RestController,@Autowired,@Qualifier,@Configuration,@Bean,@Transactional, etc.), and what are they used for?
- Stream API
- Explain how to use the Java Stream API to process collections (for example, filtering, mapping, grouping, and aggregation) in a functional style. Give a few examples of typical operations you would implement with streams.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.