0% found this document useful (0 votes)
55 views4 pages

Danske Bank Java Interview QA

Uploaded by

deepnew
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views4 pages

Danske Bank Java Interview QA

Uploaded by

deepnew
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Danske Bank Java Developer Interview Questions & Answers

1. Core Java

Q: What are the differences between HashMap, LinkedHashMap, and TreeMap?


A: HashMap is unordered, LinkedHashMap maintains insertion order, TreeMap sorts by keys.

Q: Explain immutability in Java and how to make a class immutable.


A: Make class final, all fields private and final, no setters, and return copies of mutable objects.

Q: How does Garbage Collection work in Java?


A: GC automatically frees memory by destroying unreachable objects using generational GC (Young/Old
Gen).

Q: Difference between abstract class and interface?


A: Abstract classes can have state and constructors, interfaces can't (prior to Java 8). Interfaces support
multiple inheritance.

Q: What is a functional interface?


A: An interface with a single abstract method. Used in lambda expressions. Example: Runnable,
Comparator.

Q: Explain synchronized vs concurrent collections.


A: Synchronized blocks access using intrinsic locks; Concurrent collections (e.g., ConcurrentHashMap)
offer better concurrency.

Q: What is the use of CompletableFuture?


A: Allows asynchronous computation and chaining tasks with better control than Future.

Q: Java 8+ features?
A: Lambdas, Streams, Optional, new Date/Time API, CompletableFuture.

2. Spring & Spring Boot

Q: Explain Dependency Injection and Inversion of Control.


A: IoC is the principle, DI is the implementation—Spring injects dependencies at runtime.

Q: Difference between @Component, @Service, @Repository, @Controller?


A: All are @Component types, used for different layers: service, DAO, controller.

Q: How does Spring Boot auto-configuration work?


A: Uses @EnableAutoConfiguration and classpath scanning to configure beans automatically.

Q: How does Spring Security work?


A: Uses filters and AuthenticationManager to intercept and secure HTTP requests.

Q: Difference between @RequestParam, @PathVariable, and @RequestBody?


A: @RequestParam for query params, @PathVariable for URI segments, @RequestBody for JSON payload.

Page 1
Danske Bank Java Developer Interview Questions & Answers

Q: How do you manage exceptions in Spring Boot?


A: Using @ControllerAdvice with @ExceptionHandler.

Q: What are Bean scopes in Spring?


A: singleton, prototype, request, session, application, websocket.

Q: How do you externalize configuration?


A: Using [Link], [Link], Spring Cloud Config.

3. JPA / Hibernate

Q: Difference between JPA and Hibernate?


A: JPA is a specification, Hibernate is an implementation of it.

Q: What is lazy loading vs eager loading?


A: Lazy fetches associations on demand, eager fetches immediately.

Q: Explain Entity Lifecycle in JPA.


A: States: New → Managed → Detached → Removed.

Q: What is N+1 problem?


A: Occurs when fetching collection causes many extra queries; solve with fetch joins.

Q: How to implement relationships in JPA?


A: Use annotations like @OneToMany, @ManyToOne, etc.

Q: What is a Criteria Query?


A: Type-safe, programmatic way to build dynamic queries.

Q: How to write custom queries?


A: Use @Query annotation with JPQL or native SQL.

4. Microservices & Architecture

Q: What are microservices?


A: Small, independently deployable services focused on specific business capabilities.

Q: How do services communicate?


A: Typically via REST APIs, messaging systems (Kafka, RabbitMQ).

Q: What is an API Gateway?


A: Single entry point for routing, authentication, rate limiting (e.g., Spring Cloud Gateway).

Q: What is service discovery?


A: Dynamically registers and finds services (Eureka, Consul).

Q: How do you manage configuration across services?


A: Using Spring Cloud Config or centralized config stores.

Page 2
Danske Bank Java Developer Interview Questions & Answers

Q: What is circuit breaker?


A: Prevents cascading failures by stopping calls to failing services (Resilience4j, Hystrix).

Q: How to trace/log requests across microservices?


A: Using Spring Sleuth and Zipkin/Jaeger.

Q: How to scale microservices?


A: Horizontally with container orchestration (Docker, Kubernetes).

5. Payments Domain

Q: Explain credit transfer/SEPA flow.


A: Originator → Bank → Clearing System → Beneficiary Bank → Account.

Q: What are clearing and settlement?


A: Clearing: validation & netting of transactions. Settlement: actual fund transfer.

Q: How to ensure idempotency in payments?


A: Use unique transaction IDs and track processed operations.

Q: How to handle duplicate transactions?


A: De-duplication logic based on transaction ID or hash.

Q: Challenges in real-time systems?


A: Low latency, consistency, concurrency, resilience.

Q: How to handle retries/failures?


A: Use retry patterns, exponential backoff, message queues.

6. DevOps & CI/CD

Q: How to deploy Spring Boot apps?


A: Package as JAR, deploy with Docker, run on K8s or cloud platforms.

Q: Experience with Docker/Kubernetes?


A: Containerization of microservices, orchestration using deployments/services.

Q: CI/CD tools used?


A: Jenkins, GitHub Actions, GitLab CI for build-test-deploy pipelines.

Q: How to monitor Spring Boot apps?


A: Use Actuator, Prometheus, Grafana for metrics and health checks.

7. Testing

Q: How to write unit tests?


A: Use JUnit, Mockito to test business logic in isolation.

Page 3
Danske Bank Java Developer Interview Questions & Answers

Q: Difference between @Mock and @MockBean?


A: @Mock is for unit tests, @MockBean is used to mock beans in Spring context.

Q: How to test REST APIs?


A: Use @WebMvcTest, TestRestTemplate, MockMvc.

Q: What is Testcontainers?
A: A library to spin up Docker containers for integration tests (DB, Kafka, etc).

8. Behavioral / Situational

Q: Describe a production issue you handled.


A: Give a STAR-based example: situation, task, action, result.

Q: How do you handle conflicting priorities?


A: Prioritize based on business value, communicate clearly, involve stakeholders.

Q: Why Danske Bank?


A: Highlight interest in fintech, stable work culture, and growth opportunities.

Q: Are you comfortable with Agile?


A: Yes, experienced in Scrum/Kanban, participate in standups, sprints, retrospectives.

Q: Challenging bug you fixed?


A: Give specific issue, debugging steps, root cause, and resolution.

9. Coding Examples

Q: Detect duplicate transactions in a stream?


A: Use Set or Map to store seen IDs; if already exists, it's a duplicate.

Q: Implement LRU Cache?


A: Use LinkedHashMap with access order or custom Doubly Linked List + HashMap.

Q: Thread-safe payment processor?


A: Synchronize shared resources or use concurrent structures like BlockingQueue.

Q: Parse and validate payment message?


A: Use Jackson for JSON, JAXB for XML, and write validation logic (e.g., schema, fields).

Page 4

You might also like