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 primarily focused on OOPS in Java and how Multithreading is achieved in Java and the interviewer asked questions revolving around that only.
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.
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.
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.
What's the difference between User thread and Daemon thread?
User and Daemon are basically two types of thread used in Java by using a ‘Thread Class’.
User Thread :
1) JVM waits for user threads to finish their tasks before termination.
2) These threads are normally created by the user for executing tasks concurrently.
3) They are used for critical tasks or core work of an application.
4) These threads are referred to as high-priority tasks, therefore are required for running in the foreground.
Daemon Thread :
1) JVM does not wait for daemon threads to finish their tasks before termination.
2) These threads are normally created by JVM.
3) They are not used for any critical tasks but to do some supporting tasks.
4) These threads are referred to as low priority threads, therefore are especially required for supporting background tasks like garbage collection, releasing memory of unused objects, etc.
Difference b/w Runnable Interface and Callable Interface
Both Runnable and Callable interfaces are generally used to encapsulate tasks that are needed to be executed by another thread. But there are some differences between them as given below :
Runnable Interface :
1) It does not return any result and therefore, cannot throw a checked exception.
2) It cannot be passed to invokeAll method.
3) It was introduced in JDK 1.0.
4) It simply belongs to Java.lang.
5) It uses the run() method to define a task.
6) To use this interface, one needs to override the run() method.
Callable Interface :
1) It returns a result and therefore, can throw an exception.
2) It can be passed to invokeAll method.
3) It was introduced in JDK 5.0, so one cannot use it before Java 5.
4) It simply belongs to java.util.concurrent.
5) It uses the call() method to define a task.
6) To use this interface, one needs to override the call() method.
What is thread starvation?
Thread starvation is basically a situation or condition where a thread won’t be able to have regular access to shared resources and therefore is unable to proceed or make progress. This is because other threads have high priority and occupy the resources for too long. This usually happens with low-priority threads that do not get CPU for its execution to carry on.
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.
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.
This round had questions revolving mainly around Spring and MVC Architecture.
How to enable debugging log in the spring boot application?
Debugging logs can be enabled in three ways -
1) We can start the application with --debug switch.
2) We can set the logging.level.root=debug property in application.property file.
3) We can set the logging level of the root logger to debug in the supplied logging configuration file.
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 is the root application context in Spring MVC? How is it loaded?
In Spring MVC, the context loaded using ContextLoaderListener is called the "root" application context which belongs to the whole application while the one initialized using DispatcherServlet is actually specific to that servlet.
Technically, Spring MVC allows multiple DispatcherServlet in a Spring MVC web application and so multiple such contexts each specific for respective servlet but having the same root context may exist.
What are the different properties of MVC routes?
MVC routes are accountable for governing which controller method will be executed for a given URL. Thus, the URL comprises of the following properties :
1) Route Name : It is the URL pattern which is used for mapping the handler.
2) URL Pattern : It is another property containing the literal values as well as variable placeholders (known as URL parameters).
3) Defaults : This is the default parameter value assigned at the time of parameter creation.
4) Constraints : These are used for applying against the URL pattern for more narrowly defining the URL matching it.
How is the routing carried out in MVC?
1) The RouteCollection contains a set of routes that are responsible for registering the routes in the application.
2) The RegisterRoutes method is used for recording the routes in the collection.
3) The URL patterns are defined by the routes and a handler is used which checks the request matching the pattern.
4) The MVC routing has 3 parameters.
4.1) The first parameter determines the name of the route.
4.2) The second parameter determines a specific pattern with which the URL matches.
4.3) The third parameter is responsible for providing default values for its placeholders.
Difference b/w View and Partial View
View :
1) The view is not as lightweight as that of Partial view.
2) The view has its own layout page.
3) The Viewstart page is rendered just before rendering any view.
4) The view can have markup tags of HTML such as HTML, head, body, title, meta, etc.
Partial View :
1) Partial view, as the name suggests, is lightweight than View.
2) The partial view does not have its own layout page.
3) Partial view is designed particularly for rendering within the view.
4) The partial view does not contain any markup.
This is a cultural fitment testing round. HR was very frank and asked standard questions. Then we discussed about my role.
Tell me something not there in your resume.
If you get this question, it's an opportunity to choose the most compelling information to share that is not obvious from
your resume.
Example :
Strength -> I believe that my greatest strength is the ability to solve problems quickly and efficiently, which makes me
unique from others.
Ability to handle Pressure -> I enjoy working under pressure because I believe it helps me grow and become more
efficient.
Tip : Emphasize why you were inspired to apply for the job. You can also explain that you are willing to invest a great
deal of energy if hired.
These are generally very open ended questions and are asked to test how quick wit a candidate is. So there is
nothing to worry about if you have a good command over your communication skills and you are able to propagate
your thoughts well to the interviewer.
Why should we hire you ?
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.
Tip 4 : Since everybody in the interview panel is from tech background, here too you can expect some technical
questions. No coding in most of the cases but some discussions over the design can surely happen.
.