Tip 1 : Go through all the previous interview experiences from Codestudio and Leetcode.
Tip 2 : Do at-least 2 good projects and you must know every bit of them.
Tip 1 : Have at-least 2 good projects explained in short with all important points covered.
Tip 2 : Every skill must be mentioned.
Tip 3 : Focus on skills, projects and experiences more.
This round started with some basic questions from Java followed by some questions from OOPS in Java and standard Java 8 questions.
What are the advantages of Packages in Java?
There are various advantages of defining packages in Java.
i) Packages avoid the name clashes.
ii) The Package provides easier access control.
iii) We can also have the hidden classes that are not visible outside and used by the package.
iv) It is easier to locate the related classes.
Why Java is platform independent and JVM platform dependent?
JVM is platform dependent because it takes java byte code and generates byte code for the current operating
system. So Java software is platform dependent but Java language is platform independent because different
operating system have different JVMs.
Which among String or String Buffer should be preferred when there are lot of updates required to be done in the
data?
StringBuffer is mutable and dynamic in nature whereas String is immutable. Every updation / modification of String
creates a new String thereby overloading the string pool with unnecessary objects. Hence, in the cases of a lot of
updates, it is always preferred to use StringBuffer as it will reduce the overhead of the creation of multiple String
objects in the string pool.
How would you differentiate between a String, StringBuffer, and a StringBuilder?
1) Storage area : In string, the String pool serves as the storage area. For StringBuilder and StringBuffer, heap
memory is the storage area.
2) Mutability : A String is immutable, whereas both the StringBuilder and StringBuffer are mutable.
3) Efficiency : It is quite slow to work with a String. However, StringBuilder is the fastest in performing operations. The
speed of a StringBuffer is more than a String and less than a StringBuilder. (For example appending a character is
fastest in StringBuilder and very slow in String because a new memory is required for the new String with appended
character.)
4) Thread-safe : In the case of a threaded environment, StringBuilder and StringBuffer are used whereas a String is
not used. However, StringBuilder is suitable for an environment with a single thread, and a StringBuffer is suitable for
multiple threads.
Explain the use of final keyword in variable, method and class
In Java, the final keyword is used as defining something as constant /final and represents the non-access modifier.
1) final variable :
i) When a variable is declared as final in Java, the value can’t be modified once it has been assigned.
ii) If any value has not been assigned to that variable, then it can be assigned only by the constructor of the class.
2) final method :
i) A method declared as final cannot be overridden by its children's classes.
ii) A constructor cannot be marked as final because whenever a class is inherited, the constructors are not inherited.
Hence, marking it final doesn't make sense. Java throws compilation error saying - modifier final not allowed here
3) final class :
i) No classes can be inherited from the class declared as final. But that final class can extend other classes for its
usage.
What is meant by Interface?
Multiple inheritances cannot be achieved in java. To overcome this problem the Interface concept is
introduced. An interface is a template which has only method declarations and not the method implementation.
Some imp. points about Interface :
1) All the methods in the interface are internally public abstract void.
2) All the variables in the interface are internally public static final that is constants.
3) Classes can implement the interface and not extends.
4) The class which implements the interface should provide an implementation for all the methods declared in the
interface.
Difference between Abstract class and Interface.
The differences between Abstract Class and Interface are as follows :
Abstract Class:
1) Abstract classes have a default constructor and it is called whenever the concrete subclass is instantiated.
2) It contains Abstract methods as well as Non-Abstract methods.
3) The class which extends the Abstract class shouldn’t require the implementation of all the methods, only Abstract
methods need to be implemented in the concrete sub-class.
4) Abstract class contains instance variables.
Interface:
1) It doesn’t have any constructor and couldn’t be instantiated.
2) The abstract method alone should be declared.
3) Classes that implement the interface should provide the implementation for all the methods.
4) The interface contains only constants.
What are some standard Java pre-defined functional interfaces?
Some of the famous pre-defined functional interfaces from previous Java versions are Runnable, Callable,
Comparator, and Comparable. While Java 8 introduces functional interfaces like Supplier, Consumer, Predicate, etc.
Please refer to the java.util.function doc for other predefined functional interfaces and its description introduced in
Java 8.
Runnable: use to execute the instances of a class over another thread with no arguments and no return value.
Callable: use to execute the instances of a class over another thread with no arguments and it either returns a value
or throws an exception.
Comparator: use to sort different objects in a user-defined order
Comparable: use to sort objects in the natural sort order
What are the features of a lambda expression?
Below are the two significant features of the methods that are defined as the lambda expressions:
1) Lambda expressions can be passed as a parameter to another method.
2) Lambda expressions can be standalone without belonging to any class.
This round had questions from Microservices , Spring Boot and Hibernate. The interviewer was quite freindly and also helped wherever I was stuck.
What Are the Basic Annotations that Spring Boot Offers?
The primary annotations that Spring Boot offers reside in its "org.springframework.boot.autoconfigure" and its sub-
packages. Here are a couple of basic ones :
@EnableAutoConfiguration – to make Spring Boot look for auto-configuration beans on its classpath and
automatically apply them.
@SpringBootApplication – used to denote the main class of a Boot Application. This annotation combines
@Configuration, @EnableAutoConfiguration, and @ComponentScan annotations with their default attributes.
Explain @RestController annotation in Sprint boot?
It is a combination of @Controller and @ResponseBody, used for creating a restful controller. It converts the
response to JSON or XML. It ensures that data returned by each method will be written straight into the response
body instead of returning a template.
What is dependency Injection?
The process of injecting dependent bean objects into target bean objects is called dependency injection.
1) Setter Injection: The IOC container will inject the dependent bean object into the target bean object by calling the
setter method.
2) Constructor Injection: The IOC container will inject the dependent bean object into the target bean object by calling
the target bean constructor.
3) Field Injection: The IOC container will inject the dependent bean object into the target bean object by Reflection
API.
What is the @Controller annotation used for? How can you create a controller without an annotation?
The @Controller is a Spring MVC annotation to define Controller but in reality, it's just a stereotype annotation. You
can even create a controller without @Controller by annotating the Spring MVC Controller classes using
@Component annotation. The real job of request mapping to the handler method is done using @RequestMapping
annotation.
What does the @SpringBootApplication annotation do internally?
The @SpringBootApplication annotation is equivalent to using @Configuration, @EnableAutoConfiguration,
and @ComponentScan with their default attributes. Spring Boot enables the developer to use a single annotation
instead of using multiple. But, as we know, Spring provided loosely coupled features that we can use for each
annotation as per our project needs.
Can you tell the difference between setMaxResults() and setFetchSize() of Query?
setMaxResults() the function works similar to LIMIT in SQL. Here, we set the maximum number of rows that we want
to be returned. This method is implemented by all database drivers.
setFetchSize() works for optimizing how Hibernate sends the result to the caller for example: are the results buffered,
are they sent in different size chunks, etc. This method is not implemented by all the database drivers.
What are the concurrency strategies available in hibernate?
Concurrency strategies are the mediators responsible for storing and retrieving items from the cache. While enabling
second-level cache, it is the responsibility of the developer to provide what strategy is to be implemented to decide for
each persistent class and collection.
Following are the concurrency strategies that are used :
1) Transactional: This is used in cases of updating data that most likely causes stale data and this prevention is most
critical to the application.
2) Read-Only: This is used when we don't want the data to be modified and can be used for reference data only.
3) Read-Write: Here, data is mostly read and is used when the prevention of stale data is of critical importance.
4) Non-strict-Read-Write: Using this strategy will ensure that there wouldn't be any consistency between the database
and cache. This strategy can be used when the data can be modified and stale data is not of critical concern.
Can you tell something about the N+1 SELECT problem in Hibernate?
N+1 SELECT problem is due to the result of using lazy loading and on-demand fetching strategy.
Let's take an example.
If you have an N items list and each item from the list has a dependency on a collection of another object,
say bid. In order to find the highest bid for each item while using the lazy loading strategy, hibernate has to first fire 1
query to load all items and then subsequently fire N queries to load big of each item. Hence, hibernate actually ends
up executing N+1 queries.
Explain the working of Microservice Architecture.
Microservice architectures consist of the following components :
1) Clients: Different users send requests from various devices.
2) Identity Provider: Validate a user's or client's identity and issue security tokens.
3) API Gateway: Handles the requests from clients.
4) Static Content: Contains all of the system's content.
5) Management: Services are balanced on nodes and failures are identified.
6) Service Discovery: A guide to discovering the routes of communication between microservices.
7) Content Delivery Network: Includes distributed network of proxy servers and their data centers.
8) Remote Service: Provides remote access to data or information that resides on networked computers
and devices.
What issues are generally solved by spring clouds?
The following problems can be solved with spring cloud :
1) Complicated issues caused by distributed systems: This includes network issues, latency problems, bandwidth
problems, and security issues.
2) Service Discovery issues: Service discovery allows processes and services to communicate and locate each other
within a cluster.
3) Redundancy issues: Distributed systems can often have redundancy issues.
4) Load balancing issues: Optimize the distribution of workloads among multiple computing resources, including
computer clusters, central processing units, and network links.
5) Reduces performance issues: Reduces performance issues caused by various operational overheads.
This was a Technical Cum HR round where I was first asked some basic Java related concepts and then we discussed
about my expectations from the company , learnings and growth in the forthcomig years. I would suggest be honest and
try to communicate your thoughts properly in these type of rounds to maximise your chances of getting selected.
Why should we hire you ?
What are your expectations from the company?
How was your overall interview experience?
What are your strengths and weakness according to you?
Where do you see yourself in the next 5 years?
Why are you looking for a job change?
Tip 1 : The cross questioning can go intense some time, think before you speak.
Tip 2 : Be open minded and answer whatever you are thinking, in these rounds I feel it is important to have opinion.
Tip 3 : Context of questions can be switched, pay attention to the details. It is okay to ask questions in these round,
like what are the projects currently the company is investing, which team you are mentoring. How all is the work
environment etc.

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
Which type of comments is used to comment on single lines of Java code?
i am interested in this.