Enterprise Minds
Monocept Interview Questions and Answers
Q1. How to handle exception, if any 3rd party operation is down
Use try-catch block to handle the exception and provide fallback mechanism
Wrap the 3rd party operation in a try-catch block
Catch the specific exception thrown by the operation
Provide a fallback mechanism to handle the exception
Log the exception for debugging purposes
Q2. We are given List of Integers, we have to replace odd numbers with it's square using stream
Replace odd numbers with their square using stream on a given List of Integers.
Use stream() method to convert the List of Integers into a stream.
Use map() method to apply the square function to each odd number.
Use filter() method to filter out even numbers.
Use collect() method to convert the stream back to a List.
Example: List
numbers = Arrays.asList(1, 2, 3, 4, 5); numbers.stream().map(n -> n % 2 == 0 ? n : n * n).collect(Collectors.toList());
Q3. There are 2 beans, how to select one of them
Choose based on requirements and configuration
Identify the requirements for the bean
Check the configuration of both beans
Choose the bean that meets the requirements and has the appropriate configuration
Q4. How can you make a class Immutable.
To make a class Immutable, we need to ensure that its state cannot be modified after creation.
Make all fields final and private
Do not provide any setters
Ensure that any mutable objects are not exposed through getters
Make the class final or use private constructor to prevent subclassing
Override equals() and hashCode() methods to ensure that objects can be compared based on their state
Q5. Difference between @Qualifier and @ Primary
The @Qualifier annotation is used to differentiate between beans of the same type, while @Primary is used to give priority to a bean.
Both annotations are used to resolve ambiguity when multiple beans of the same type are present.
@Qualifier is used to specify a unique identifier for a bean, which can be used to inject that specific bean.
@Primary is used to give priority to a bean when multiple beans of the same type are present. If no @Qualifier is specified, the @Primary bean...read more
Q6. Difference between Spring and Spring Boot
Spring is a framework for building Java applications, while Spring Boot is a tool for simplifying and automating the configuration of Spring applications.
Spring provides a comprehensive framework for building Java applications, including features such as dependency injection, AOP, and MVC.
Spring Boot is built on top of Spring and provides a streamlined way to configure and run Spring applications, with features such as auto-configuration and embedded servers.
Spring Boot reduc...read more
Q7. What is singleton Pattern
Singleton pattern restricts the instantiation of a class to one object.
Used when only one instance of a class is required throughout the application
Provides a global point of access to the instance
Implemented by making the constructor private and providing a static method to access the instance
Example: java.lang.Runtime#getRuntime()
Example: Database connection pool
Q8. What are annotations
Annotations are a form of metadata that provide additional information about code.
Annotations are denoted by the '@' symbol and can be applied to classes, methods, fields, and parameters.
They can be used to provide information to the compiler, tools, and runtime environments.
Examples of annotations include @Override, @Deprecated, and @SuppressWarnings.
Annotations can also be used to create custom annotations for specific use cases.
Q9. Different CRUD operations
CRUD stands for Create, Read, Update, and Delete. These are the basic operations performed on data in a database.
Create - inserting new data into the database
Read - retrieving data from the database
Update - modifying existing data in the database
Delete - removing data from the database
Interview Process at Monocept
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month