Deutsche Bank
10+ Coherent Mining Solutions Interview Questions and Answers
Q1. Write code for Builder/Factory Pattern, basically anything other than Singleton
Builder/Factory Pattern is used to create objects with complex initialization logic.
Builder Pattern separates the construction of a complex object from its representation.
Factory Pattern creates objects without specifying the exact class of object that will be created.
Builder Pattern is often used to create immutable objects with many optional parameters.
Factory Pattern is used when there is a need to create multiple instances of a class with similar characteristics.
Q2. Write snippet for creating an Entity Class.
Creating an Entity Class in Java
Define class with @Entity annotation
Add @Id annotation for primary key
Include fields with appropriate data types
Q3. Why is Redux used in React
Redux is used in React to manage the application state in a predictable way.
Centralized state management for React applications
Predictable state changes with actions and reducers
Easier debugging and testing of state changes
Facilitates communication between components
Q4. Write Snippet to create two beans
Creating two beans in Java using Spring framework
Use @Component annotation to define a bean
Specify the bean name using @Component("beanName")
Use @Autowired annotation to inject one bean into another
Q5. Transaction Management in Hibernate
Transaction management in Hibernate ensures ACID properties for database operations.
Hibernate provides built-in transaction management support through Session interface.
Transactions can be managed programmatically using beginTransaction(), commit(), and rollback() methods.
Hibernate also supports declarative transaction management using annotations like @Transactional.
Transactions in Hibernate ensure Atomicity, Consistency, Isolation, and Durability for database operations.
Q6. Attached Entity vs Detached Entity
Attached entities are actively managed by the persistence context, while detached entities are no longer actively managed.
Attached entities are being managed by the persistence context and any changes made to them will be automatically synchronized with the database.
Detached entities are not being managed by the persistence context and changes made to them will not be automatically synchronized with the database.
Entities become detached when the persistence context is closed,...read more
Q7. Filter a List using Streams
Filter a List using Streams in Java
Use the filter() method to apply a predicate to each element in the stream
Use collect() method to convert the stream back to a List
Example: List
names = Arrays.asList("Alice", "Bob", "Charlie"); List filteredNames = names.stream().filter(name -> name.startsWith("A")).collect(Collectors.toList());
Q8. Different Types of Autowiring
There are three types of autowiring in Spring: byType, byName, and constructor.
byType: Spring looks for a bean of the same type and injects it.
byName: Spring looks for a bean with the same name and injects it.
constructor: Spring looks for a constructor and injects the arguments.
Q9. Sort an Employee HashMap
Sort an Employee HashMap based on keys or values
Use TreeMap to automatically sort by keys
Use Comparator to sort by values
Convert HashMap to List and then sort
Q10. Lazy vs Eager Fetch
Lazy fetch loads data only when needed, while eager fetch loads all related data upfront.
Lazy fetch is more efficient for performance as it only loads data when required.
Eager fetch can lead to performance issues by loading unnecessary data upfront.
Lazy fetch is the default behavior in JPA, while eager fetch needs to be explicitly specified.
Example: Lazy fetch can be used for loading a list of items in a shopping cart only when the user views the cart.
Example: Eager fetch can...read more
More about working at Deutsche Bank
Top Java Full Stack Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month