Java Spring Boot 2.5 Years Interview Experience

so hey guys today we have Sues and he's having two and a half year of experience in Java and spring boot so let's get started hey hi sues how are you hello fan I'm good what about you yes I'm also good shall we start yeah we can show you okay can you please introduce yourself in brief and uh your recent projects yeah sure yeah so I'm sues a I'm currently working in virtusa as a software engineer okay I have from the last uh I have two years of experience uh in contributing the financial project I have contributed in the to the City Bank in their investment domain so there I have majorly worked on two projects uh actually working on currently so the first one is Global Communication automation okay and the another one is uh the pker an error handling trade application so the Global Communication automation is basically a microservice based architecture project MH so we we have around 7 to8 services and in vulker which is a error handling trade application where I have basically worked on integrating sidol value integration so how your microservices are communicating with each other uh yeah they are communicating with the help of uh we are actually currently using native programming we have used web client to communicate uh to establish a communication between each microservices web client yeah earlier it was on R template can you please brief on this uh like what is this web client yeah so as I mentioned it comes in the reactive programming so it is a an asynchronous way of communicating between establishing a communication between two microservices uh okay this this communication is a non-blocking so we can have uh we can have we can have the communication established between two microservices asynchronously and in a non-blocking way okay okay so cannot our microservices uh communicate directly uh is my voice low uh it's good pretty low but uh I can hear you okay so uh like uh cannot our microservices connect uh or communicate directly uh with the apis or can okay we can we can establish a communication with the help of APs as well okay okay uh okay and uh and like uh as you said you were working on uh error handling uh project also so uh like what what are your what were your basic approach to error handling and what were the uh basic things that you were doing in error handling so just to correct you it's an error trade handling application not an error handling application basically yeah we basically receives an error trade from the upstream and Maps we we process and Maps those in our staging table we keep the those in our staging table and and create an output table and send this to the downstream based on the mapping okay okay got it before moving into the next question do you know that we have designed a complete interview preparation package structured step by step containing 16 PDFs uh so it's basically a One-Stop solution to crack any interview uh this package covers score Java spring framework Maven git spring boot scenario based question Spring Security spring MVC spring data jpa microservices hibernate General Java coding questions stream API coding questions and many more the best part is that people have been telling me that they cracked their interviews with this material and uh there is a 99% chance that interviewers with ask questions from this package so after this interview I will share a link with you to get this and also I will add in the description of this video so now moving to our questions okay yes uh can you tell me uh what's the purpose of spring boot application annotation yeah spring board annotation uh the purpose of annotation which we use in the springboard right M yeah uh so so the annotations are basically used uh to Define any class of a spring board as a bean okay basically so basically when we are anting we have the generalized compon uh we have a generalized annotation named as component M so when we when we Define any class as an with a help of adate component we so ioc container basically finds it as a finds it as a bean so it would basically create the bean of those and maintain the life cycle of those Bean in that IC container so wherever the annotations will be there the bean of those class will be created okay and it will be stored in uh ioc container manage it's uh so that spring ioc coner will be responsible for managing the whole life cycle of that bean okay okay so uh okay uh moving ahead uh uh what are the components that makes up Spring boot application annotation yeah uh the components right earlier to Spring boot we used to use have uh like we have it's basically combination of component scan which basically scans our whole spring boot application the class path okay and it also includes that uh configuration at theate configuration and as well as enable auto configuration which basically enables an auto configuration yeah these are the three things the three component okay okay okay so if an application fails to start with an exception related to component scanning uh so what adjustments might you make uh to the spring boot application annotations attribute if if an application gets failed while scanning the application right well component scan so first I'll check uh the the approach I guess uh it's related to the the proper structuring uh it's related to the structuring of the project right I will check check whether the whether the exact class is uh actually present in that in those package which is getting scanned okay I will check the exact class path if it is correct or not okay uh can we uh add some attribute in uh enable auto configuration uh like exclude attribute something like that yeah yeah we can have uh we can have those attribute as well let's say we want we know that we have uh in in that enable auto configuration uh we want some of the configurations or let's say we want to disable our tomat server MH or any any configuration which we want to we don't want in uh get started when our application gets start right yeah so in that time we can we can include those attributes there in that exclude part okay okay so so uh moving ahead have you uh uh worked uh I mean uh do you know what is a spring boot starter and like uh what are their purposes yeah spring board starter basically it's it's a dependency we used okay so for for basically creating the whole uh a springboard starter is basically consist of different dependences a combination of different dependencies which is responsible for starting our whole application so if we are adding the springboard starter web application web spring boot starter web dependency in our application so whatever the whatever the dependencies are required to create an application as a to create a to start our web application will be included let's say we are having springboard starter web right so it will it will have uh spring web MVC spring uh spring web dependency as well as uh Tomcat uh or I guess say I would say the server will be added Tomcat server will be will be the default server which will be added so there are different dependencies which which will be included in that spring yeah okay so let's say your project needs to integrate a third party Library uh how would you proceed to create a starter for this Library um so so we wanted to include any another library right we so we will go basically thir party Library uh we can we can go to the Marin repository and add those in our dependenc any Library okay or uh yeah and let's say we want there are some dependencies let's say we have um let's say we have uh tomat as our default server right so we we don't want that we don't want tomcat to be used as a default server we want let's say we want to use a JY so what we do what we will do is in our in our in the structure in the structure of our dependency we will basically exclude our tomcat and we'll add We'll add the the dependency related to the JT spring board starter JT so in a way any any dependencies so this is uh you are disabling Tom Cat en enabling JY server right yeah basically a new dependency which has been added instead of okay let's say any extra let's as you mentioned if you want to add any new dependency or third party dependency we can get those dependencies from M repository any of anything so we will we can get the exact dependency with the version and the artifact and the group ID we can add those in our uh if if there is a version conflict they we can add those in the dependency management as well okay uh okay okay can you please tell me what is uh spring boot uh profile annotation at theate profile okay uh so spring boot atate profile annotation is basically let's say we want to uh we want to have we want to use the use our Bean for the specific environment right we can we can specify this that specific environment and at theate profile annotation let's say we want uh we want any Bean to be loaded or configured only and in the production environment or in or or in the only lower environment like a DA or U okay so at that at that time I can I can add that Dev environment property that Dev environment in that or the Local H let's say we can in that we can add those in our atate profile annotation basically defining the environment where we want to configure our specific Bean basically us in our configuration uh configuration part okay so how would you uh how would you uh create different environments like production environments Dev environments testing environment so I can create those environment uh you mean we have different application properties uh we basically create and uh we basically specify the properties specific to those applic uh to those environment in that application do properties only let's say we have uh we basically in our project maintain three three environment like Dave U and prod so and in in each environment we have three region AAC AAC Nam and emia so we basically defines the property as per our environment as as as for our region as well okay so Su uh how do you perform testing in your project uh can you tell me step by step so basically testing of for a whole application right uhhuh yeah uh like uh uh which testing you guys prefer uh there are different type of testing like integration testing uh and other types as well so yeah please go ahead yeah so in our in our appli we basically performs uh I'll start with the let's say in our GC application right we have different We have basically different Services communicating with each other okay so so in our testing we basically first we check our application whether it's running properly our specific service has started or not if it is started then uh before starting the testing I would uh like to give an overview of how exact project goes through and okay and uh I can give you the answer directly as well okay the for the for the testing purpose right we basically performs the proper the proper uh uh we have a different Services communicate we have integrated different external Services let's say we have visibility services so uh when we perform uh testing of a specific service named as a visibility service so we check whether whether that visibility service has properly getting the response from the external service which we have implemented right which we have integated so in that case wherever the integration of where wherever we have external Services which are integrating MH we basically check whether the integration is working fine as with the help of integration testing then we when we check our apis whatever the API which we are using with the help of API testing in a postman then after after everything is properly working we basically deploy and test on a Dev we perform a sanity test we perform a sanity test of our whole end to end application okay and as once the sanity test is performed we basically give it to the uh uh to the performance yeah performance testing team first of all they performs the performance testing then the U the also to the U testing team so basically they perform the in to end testing of okay so do you guys uh write junit test cases as well right uh we basically did not have yet written those uh test cases yet we are have now started writing the junit test cases for our application it was now it was not there but do you know how to write yeah I am learning now okay okay so do you know about mokito framework uh uh okay so like why do we need this framework uh basically it's a testing as you mentioned right it's a test it's used for a testing purpose so uh so let's say we have a com we have our controller class and it has a dependency on service class right and so so basically with the help of mockito framework we can mock the beans which are dependent and we can we can basically Mo create fake data right yeah basically create the fake data uh we will not exactly calling to that service we will only returning while while writing the junit test we will only we will have the fake or dummy data which we will use for the testing purpose okay so do you know about sonar coverage uh and all these stuff uh in my current project I have not worked on that but I do have an understanding how what exactly so why sonar coverage is required like uh it depends a few companies required 80% and some 85 so why do we need uh this sonar coverage yeah Sonar coverage is basically basically defines our uh the the code coverage or the how robust or application can be uh or how good our application is how many how many percentage of test is covered so that so that basically it is responsible for making our application robust and okay just to find uh just to find the the what I can say the coverage of the whole code is good enough to the is good enough so that the application will not fail directly in the production environment or in the higher environment right yeah yeah yeah so basically we maintain the code quality we we can track off our code quality with this with the help of sonar Cube and sonar L okay so what a good percentage uh for sonar coverage uh it's around 80% if it is good 80% yeah okay even in our application we have targeted of 80% only okay if it is 80% of whole class it is good so do we have some uh disadvantages of spring boot test annotation um or limitation uh yeah sometime what happen is uh when we are when we are doing a mavan install or when we are trying to start our application right uh we and we have not written the test cases as I mentioned right so it basically get fail with the help of test case failures application didn't start so for in that case what we what we have to do is we have to we have to run the application by skipping those test cases let's say we use Des skip test equal to true so D skip test uh so it will basically run will uh basically start the application by skipping those T cases okay uh okay okay got it so uh how to handle asynchronous operations in Spring boot application a synchronous operations yes uh do we have any annotation uh uh uh we I mean can we use any annotation uh to do some asynchronous operations in Spring boot application yes there are some annotations uh but I'm not very so have you heard about async annotation yeah async annotation is there but I'm not remembering how it can be used uh because I haven't experimented on that word but yeah it uh annotations are there I'm familiar I think is also there okay okay no worries uh so how do you handle session management do you know about session management session management yeah no actually I'm not aware session management could you please brief how exactly what exactly you saying of session means uh there is a term spring session like spring Cloud we have a term similar we have spring session uh which provides apis to manage session attributes across distributed environments okay actually I'm not very clear with this okay no worries uh what's the deployment mechanism in your project yeah uh for for deployment purpose we basically okay one second one second uh tell me what uh according to you what would be the best deployment strategy best deployment strategy right yeah yes uh yeah see only the uh once the testing has been performed properly from the uh from Dev end as well as from the U side from the testing site so we basically deploys it for our c purpose we basically in our project we are using team City and urban code deploy where in team City we basically creates the build of uh our of for a service once the build is created we basically check the build locks whether whether it is good it is it a success or is there any kind of vulnerability in it if any kind of vulnerability we we go on removing those and once the build is properly there it's success and we we basically deploy those build with the help of urban code deploy okay of urban code deploy we have uh we have basically configured their components uh we have basically configured components there as well as the environment so we to we take this those be and deploy it on the uh Urban code deployer this is the the the process which you this is what you are using yeah we are following there yeah okay uh okay moving ahead uh uh to we have any uh Javas mechanism for handling immutable objects uh immutable objects Java mechanisms yeah I mean uh how can we handle immutable objects or what what are immutable objects uh immutable objects let's say uh in any object which cannot which is once initialized we cannot change the state of those object which are those are called immutable let's say we have a we have a string okay which is which is a completely immutable based on the based on the concept it uses like the string constant pool the concept which it basically uses so so whenever a string is initialized it basically it uh whenever the string let's string is initialized with the help of literals right so so the so the object or the value will be stored in this spring constant pool which is area inside our he memory uhhuh so let's say we are we are creating another string with the same with the same value right the same value it will basically it will basically check whether those whether those values are already present in a string constant pool or not if it is present it will not create another object of those it will basically point the reference of that new variable to that already existing object in our string constant pool it basically reduces the memory consumption or the extra memory which we can uh which an J can have right so this is the okay so this is the way mutable okay so let's say you need to ensure that certain data within your application remains constant and secure throughout its life cycle how would you implement uh immutability for this purpose uh could you please repeat I okay let's say you need to ensure that certain data within your application remains constant and secure throughout its life CLE cycle okay how would you implement uh immutability for this purpose uh let's say we have we we will basically let's say we have any object of a CL we want uh we can make a class as an immutable completely okay just to just to ensure that all all the datas inside those all the datas inside how can we make class immutable yeah we can make the class immutable by as I mentioned right uh if you if you see the stream class which is basically an imitable it basically has the class as a final we basically don't have any kind of Setter in those we only have Getters right and whatever the fields which we have that are private and final that are private and final so whenever then object will be created yeah that that cannot be changeed or any any other any other class cannot in inherit as we have used final with that class right and and and what let's say we have used another object in our class so in that case we will be performing de copy of those object not not going for the shallow of those so so and copy a different copy will be there a different object will be created not those object yeah okay okay so uh moving ahead do you know about Java generics Java generics no I'm uh not very clear with this as well okay uh we used yeah yeah uh no worries so how how can we uh override equal method yeah uh yes uh so we can basically as I as I mentioned right uh uhuh uh in our in our immutable immutable class or let's say we have hashmap we when we want to insert any kind of value we basically we basically check whether the values is already present in our list of bucket or not MH right and in that case while checking the values we basically check with the help of with the help of hash code if the hash code of those if the hash value of or the hash code of those key is same then we will allocate that value at the same position but after that after that in the same bucket but after that in the form of Link list right okay in a form of Link list at that time when we are trying to compare we need to when we are trying to compare to already existing key and already already existing entry and new entry we basically check all both the object with the help of equals so in this case in this case we want to we actually want uh we actually want whatever the hash code are same that they should have the equals they should have be same equals right MH so basically we have an contract between hash code and equals there is a contract exist between hash code and whenever we are overriding equals as for our requirement we have to override code as well let's say any two object are having same same value right they they are showing true when they are when they are compared with the help of equals so it does mean it simply means that we have the same hash code for the both of them okay if if those are saying so which algorithm hashmap uses internally do you know uh hashmap uses basically hashing only yeah okay uh okay so do you know about Java Reflection API Java Reflection concept I'm aware but reflection API is I'm aware of the the reflection in Java so with the help of reflection what what Java uh provides is we can basically change or we can basically get the what we we can basically change the behavior or modify the behavior of an object of or the method with the help of or the class basically with the manipulate classes Constructor method with the yeah at run time we can manipulate or modify those behavior of those existing CLA okay uh is there any performance or security uh disadvantages by using this reflection for the for the reflection any security disadvantage mhm with the of so basically this can lead to Performance overhead because it bypass Javas usual Security checks and meth dispatches which are optimized by jvm okay uh okay so uh can you please tell me how does Java support functional program pramming functional programming yeah yeah a functional programming means uh like Java new features like Lambda expression stream API and all okay okay yeah so so as you mentioned in the functional programming we have a Lambda Expressions right yeah yeah in that Lambda expression we in in the in the Lambda expression is is an anonymous function which we don't have any name of that function we can directly use those function anywhere and functional interface is also the concept which is there in the function interface we we have we basically have in a single interface we basically have only one one abstract method only one abstract matter can have in the function interface then we have the concept of uh stream right Stream apis So In The Stream API we basically what I would say a stream API is basically a sequence of object which basically responsible for performing an operation mhm which basically responsible for performing uh an intermediate operation to get an output it does not stores the operation but it uh it it basically perform it does not stores the any value but it it performs those operation on demand and prepares and creates a required result we have intermediate we have initial intermediate operation as well as the final operations as well in the in the intermediate operation we basically use any kind of filtering sorting or any searching algorithm which we can use and we have we have uh method reference as well we have method reference in the method reference uh we basically you know when we are call trying to call any kind of object or any kind of method we use object do method right or let's say we are we are trying to call a method which is in a static class we use the class name dot that method right so but in case of method reference we what method reference allows us like we can directly use the class Name mhh colon uh colon uh two times that colum then after that we can directly use the method name with the help of method reference we have uh we have optional as a new feature which has been uh uh Implement which has been new given introdu with in Java it right optional basically allows basically allows us to handle null pointer any kind of null poter exception so do you use optional classes in practically uh my project I did used somewhere yeah and optional is used because we there are some null pointer exceptions which used to cause in our optimization purpose we have used those okay yeah and after that uh what I would say this and we have another uh new that date and time API which has also been introduced date time date uh that date time APS has been also there so these are the things okay okay so uh what is uh do you know about Java's thread management I'm little aware of this okay uh no worries uh moving ahead So currently you are working on which Java version it's 17 17 yeah okay so can you tell me me some new features that were introduced in Java 17 the new features right yes we have uh I'm not very aware of those future but yeah there are some uh sealed classes which uh which is there which has been introduced currently and Vector apis uh this are these are the some uh okay context right okay so uh do you know about volatile keyword you mean versatile uh no no volatile volatile volatile keyword okay yeah so in case of volatile right so the values of those variables will be change directly will be directly changed from the main memory so whatever the values will be there it will be stored directly in the main memory instead of storing those Value First into the cach then into the main memory it basically changes directly from directly communicates with the main memory stores and drives the values from there let's say in case let's say when two trades are trying to face the values right when we are not using volatile some updated values will not be there in our main memory because updated values first get stored Into Cash M then it get uh stored into the main memory so another trade let's try let's try to retrive they can they will they will have the different values for the same variable or the same thing so in order to avoid this situation we use volatile we can have the memory directly uh values directly stored in a main memory okay so uh do you know about Dynamic method dispatch Dynamic method dispatch in Java no no I'm not aware can you can you brief what exactly you you saying uh okay so basically uh it's a way uh Java decides which method to use at run time when methods are overridden in sub classes it's it's a way only right right right yeah I I am aware how it can be okay yeah uh okay moving ahead uh can you provide examples uh where abse section is effectively used in Java libraries in Java library in Java libraries I mean any example where we can see uh some AB section in Java libraries yeah we have Java libraries abstractions are I know what say abstraction and I'm not remembering exactly abstraction means we just hi Bally yeah yeah we basically the implementation only show the required details to the user right so is there any example in Java lities uh okay so when we use list we don't know uh how it is stores data okay right right right exactly we just we just use this so we can say it's an example of exraction okay yeah yeah uh okay uh can you provide examples of when to use interface versus when to extend a class when to use interface work is when to extend the class when to extend the class okay okay yeah so basically uh when we are we have we have a solid principle we basically use when we are trying to have right we basically use this a solid principle to any uh while developing or application so it's it's one of the part of the solid principle where interface segregation principle it is there there is also open and close principle is also there and is uh there is one one principle also that dependency inversion principle yes first one is first one is our single responsibility so in our in our uh what I would say interface segregation right interface segregation we basically we basically does not uh Force any client to use those interface if they are uh if they if they are not using all the methods of that interface if they are not using all the methods of interface right we don't mhm basically force in the in those case we can have then we can we can create the interface with an abstract method with a with only abstract method which is common to all which is very common to all the classes we can have those and uh so that we are basically segregating the interface instead of creating a one interface and uh one only one interface and keeping all the methods used all the methods in those interface which are used or or somewhere not used by those extended class mhm M right so in the instead of using single interface we can create one different two interfaces right two two two or more interfaces so that only dependent classes the mandatory interface methods will be in one interface and non-mandatory will be in another one so we can extend those method with the help of that specific interface basically in interface we basically Implement not extend okay yeah okay uh okay so how encapsulation enhances security uh software security and integrity yeah so so basically encapsulation right encapsulation is basically uh a binding of data data members and methods together okay so in this binding we uh let's say we have a class right we we basically creates all the variables of a of our class as a private we always keep those uh as a private so with the help of uh by doing this we basically restricts uh any direct access to those variables right but we but but those those variables can be accessed with the help of public getter and Setters we can change the value with we basically provide public getter and Setter just to just to make sure that values are not directly values are not directly changed but they but let's say they have they have uh they have the our object and with the help of object they can they can access to our methods and they can perform the restrictive restrictively use our data members or the important uh or the private members right or the secure data directly okay okay so yeah it's done from my end

Share your thoughts