Tip 1 : Must do Previously asked Interview as well as Online Test Questions.
Tip 2 : Go through all the previous interview experiences from Codestudio and Leetcode.
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.
In this round, I was first asked about the projects that I worked on in my previous company. I was also asked about the various tech stacks that I was familiar with and then the interviewer started asking me questions around Java and some basic OOPS concepts.
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.
Why are Java Strings immutable in nature?
String objects in Java are immutable by definition. This signifies that the String object's state cannot be changed once it has been created. As a result, if you try to update the value of that object rather than the values of that object, Java creates a new string object.
Because String objects are often cached in the String pool, Java String objects are immutable. Because String literals are frequently shared among numerous clients, one client's action may have an impact on the others. It improves the application's security, caching, synchronization, and performance by doing so.
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.
What do you know about JIT Compiler?
1) JIT stands for Just-In-Time and it is used for improving the performance during run time. It does the task of compiling parts of byte code having similar functionality at the same time thereby reducing the amount of compilation time for the code to run.
2) The compiler is nothing but a translator of source code to machine-executable code.
Working of JIT Compiler :
1) First, the Java source code (.java) conversion to byte code (.class) occurs with the help of the javac compiler.
2) Then, the .class files are loaded at run time by JVM and with the help of an interpreter, these are converted to machine understandable code.
3) JIT compiler is a part of JVM. When the JIT compiler is enabled, the JVM analyzes the method calls in the .class files and compiles them to get more efficient and native code. It also ensures that the prioritized method calls are optimized.
4) Once the above step is done, the JVM executes the optimized code directly instead of interpreting the code again. This increases the performance and speed of the execution.
Differentiate between ArrayList and Vector in Java.
Following are the differences between ArrayList and Vector in java :
1) Synchronization : Vector is synchronized, which means that only one thread can access the code at a time, however, ArrayList is not synchronized, which means that multiple threads can operate on ArrayList at the same time.
2)Data Growth : Both ArrayList and Vector dynamically expand and shrink to make the most use of storage space, but the manner they do it is different. If the number of elements in an array exceeds its limit, ArrayList increments 50% of the current array size, while vector increments 100%, thereby doubling the current array size.
3) Performance : ArrayList is faster than vector operations because it is non-synchronized, but vector operations are slower since they are synchronized (thread-safe). When one thread works on a vector, it acquires a lock on it, requiring any other threads working on it to wait until the lock is released.
4) Ease of Iteration : Vector can traverse over its elements using both Enumeration and Iterator, whereas ArrayList can only traverse using Iterator.
Differentiate between HashSet and TreeSet. When would you prefer TreeSet to HashSet?
Following are the differences between HashSet and TreeSet :
1) Internal implementation and speed -
1.1) HashSet : For search, insert, and remove operations, it takes constant time on average. TreeSet is slower than HashSet. A hash table is used to implement HashSet.
1.2) TreeSet : For search, insert, and delete, TreeSet takes O(Log n), which is higher than HashSet. TreeSet, on the other hand, preserves ordered data. Higher() (Returns the least higher element), floor(), ceiling(), and other operations are also supported. In TreeSet, these operations are likewise O(Log n), and HashSet does not implement them. A Self-Balancing Binary Search Tree is used to implement TreeSet (Red Black Tree). In Java, TreeSet is backed by TreeMap.
2) Way of storing elements -
The elements of a HashSet are not ordered. In Java, the TreeSet class keeps objects in a Sorted order defined by the Comparable or Comparator methods. By default, TreeSet components are sorted in ascending order. It has a number of methods for dealing with ordered sets, including first(), last(), headSet(), tailSet(), and so on.
3) Allowing Null values -
Null objects are allowed in HashSet. TreeSet does not allow null objects and throws a NullPointerException. This is because TreeSet compares keys using the compareTo() method, which throws java.lang. NullPointerException.
4) Comparison -
HashSet compares two objects in a Set and detects duplicates using the equals() method. For the same purpose, TreeSet employs the compareTo() method. If equals() and compareTo() are not consistent, that is, if equals() returns true for two equal objects but compareTo() returns zero, the contract of the Set interface will be broken, allowing duplicates in Set implementations like TreeSet.
Following are the cases when TreeSet is preferred to HashSet :
1) Instead of unique elements, sorted unique elements are required. TreeSet returns a sorted list that is always in ascending order.
2) The locality of TreeSet is higher than that of HashSet. If two entries are close in order, TreeSet places them in the same data structure and hence in memory, but HashSet scatters the entries over memory regardless of the keys to which they are linked.
3) To sort the components, TreeSet employs the Red-Black tree method. TreeSet is a fantastic solution if you need to do read/write operations regularly.
This round had questions revolving around OOPS , Spring Boot and Docker. The questions were preety decent and standard and can be answered if one has prior experience in the given tech stack.
Explain SOLID principles in Object Oriented Design.
The SOLID principle is an acronym of the five principles which is given below :
1) Single Responsibility Principle (SRP)
2) Open/Closed Principle
3) Liskov’s Substitution Principle (LSP)
4) Interface Segregation Principle (ISP)
5) Dependency Inversion Principle (DIP)
Uses of SOLID design principles :
1) The SOLID principle helps in reducing tight coupling.
2) Tight coupling means a group of classes are highly dependent on one another which we should avoid in our code.
3) Opposite of tight coupling is loose coupling and our code is considered as a good code when it has loosely-coupled classes.
4) Loosely coupled classes minimize changes in your code, helps in making code more reusable, maintainable, flexible and stable.
Explaining the 5 SOLID principles one by one :
1) Single Responsibility Principle : This principle states that “a class should have only one reason to change” which means every class should have a single responsibility or single job or single purpose. Use layers in your application and break God classes into smaller classes or modules.
2) Open/Closed Principle : This principle states that “software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification” which means you should be able to extend a class behavior, without modifying it. Using this principle separates the existing code from the modified code so it provides better stability, maintainability and minimizes changes as in your code.
3) Liskov’s Substitution Principle : According to this principle “Derived or child classes must be substitutable for their base or parent classes“. This principle ensures that any class that is the child of a parent class should be usable in place of its parent without any unexpected behavior.
4) Interface Segregation Principle : This principle is the first principle that applies to Interfaces instead of classes in SOLID and it is similar to the single responsibility principle. It states that “do not force any client to implement an interface which is irrelevant to them“. Here your main goal is to focus on avoiding fat interface and give preference to many small client-specific interfaces.
5) Dependency Inversion Principle : Two key points are here to keep in mind about this principle
a) High-level modules/classes should not depend on low-level modules/classes. Both should depend upon abstractions.
b) Abstractions should not depend upon details. Details should depend upon abstractions.
What is Garbage collector in JAVA?
1) Garbage Collection in Java is a process by which the programs perform memory management automatically.
2) The Garbage Collector(GC) finds the unused objects and deletes them to reclaim the memory. I
3) In Java, dynamic memory allocation of objects is achieved using the new operator that uses some memory and the memory remains allocated until there are references for the use of the object.
4) When there are no references to an object, it is assumed to be no longer needed, and the memory, occupied by the object can be reclaimed.
5) There is no explicit need to destroy an object as Java handles the de-allocation automatically. The technique that accomplishes this is known as Garbage Collection. Programs that do not de-allocate memory can eventually crash when there is no memory left in the system to allocate. These programs are said to have memory leaks.
Garbage collection in Java happens automatically during the lifetime of the program, eliminating the need to de-allocate memory and thereby avoiding memory leaks.
In C language, it is the programmer’s responsibility to de-allocate memory allocated dynamically using free() function.This is where Java memory management leads.
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.
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 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.
List the most commonly used instructions in Dockerfile.
1) FROM : This is used to set the base image for upcoming instructions. A docker file is considered to be valid if it starts with the FROM instruction.
2) LABEL : This is used for the image organization based on projects, modules, or licensing. It also helps in automation as we specify a key-value pair while defining a label that can be later accessed and handled programmatically.
3) RUN : This command is used to execute instructions following it on the top of the current image in a new layer. Note that with each RUN command execution, we add layers on top of the image and then use that in subsequent steps.
4) CMD : This command is used to provide default values of an executing container. In cases of multiple CMD commands the last instruction would be considered.
What command can be run to import a pre-exported Docker image into another Docker host?
This can be done using the docker load command and the syntax is : docker load -i .tar
Describe the lifecycle of Docker Container?
The different stages of the docker container from the start of creating it to its end are called the docker container life cycle.The most important stages are :
1) Created: This is the state where the container has just been created new but not started yet.
2) Running: In this state, the container would be running with all its associated processes.
3) Paused: This state happens when the running container has been paused.
4) Stopped: This state happens when the running container has been stopped.
5) Deleted: In this, the container is in a dead state.
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 forthcoming 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.
1) Why should we hire you ?
2) What are your expectations from the company?
3) How was your overall interview experience?
4) What are your strengths and weakness according to you?
5) Where do you see yourself in the next 5 years?
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
What is recursion?