Thumbnail for Java Spring Boot 4 Yrs Interview Experience by GenZ Career

Java Spring Boot 4 Yrs Interview Experience

GenZ Career

29m 35s3,851 words~20 min read
Auto-Generated

[0:00]Hey guys, today we have Ashi and she is having total four year of experience in Java Springboot and microservices domain. And those who want to give same free mock interview, please fill out the form below in the description so now let's get started.

[0:12]Hey, hello Ashi, how are you? I'm good. How are you? Yes, I'm also good. Shall we start? Yes. Okay. So Ashi, can you please introduce yourself and your recent project in brief?

[0:24]Okay, so my name is Ashi Jaiswal. I have an experience of four years. Currently, I'm working on a modernization project. It was a legacy application which we have converted into a modern by doing the modernization of the project.

[0:41]So the project basically handles the policy issuance. I'm working in the insurance domain. So I majorly handle the policy issuance, the process of policy insurance part.

[0:55]Okay, nice. So what's your day-to-day responsibilities, Ashi, there?

[0:59]So right now, so there are different types of products which are to be taken live. So right now, legacy application is also working and our modernization application is also working.

[1:12]So we have to maintain both the applications and the second thing is we have to take the existing products live in our modernization project. So that development happens based on the requirement of the products and all. So we are migrating the products.

[1:30]Okay, nice. So this is based on completely Springboot, right?

[1:34]Yes. Okay. So like, do you know the concept of dependency injection in Spring and how it is implemented?

[1:43]Okay, so we there are three types of dependency injection, constructor, setter, and field. Uh, mostly constructor dependency injection is more prominent to be used. So basically, when we use the dependency injection, it basically, it internally autowires are the the services that we are calling. For example, if we want to implement a method of the repository layer, so we can just autowire the class and we can then use the repositories.

[2:18]methods. Correct, correct. So, can you tell me a situation where constructor injection is preferred over setter injection?

[2:26]Uh, that I'm not a little confused in that.

[2:32]Okay, okay. Yeah, yeah, so, yeah, it's fine. So constructor injection is preferred when dependencies are required for the object's functionality, and it ensures that object is always in a valid state when created. It's also immutable and suitable for required dependencies.

[2:47]Okay, okay.

[2:50]Yeah, yeah. Uh, so Sakshi, uh, sorry, Ashi, can you, uh, tell me about Spring Beans, like what Spring Beans are and how do they work?

[2:59]So Spring Beans are basically the entity class we can say. So we create Spring Beans so that we can, for example, if we have a database, so we want to map the database columns with the our Springboot application, so for that we create beans so that our columns are mapped with the beans names and we can access it in the Springboot application. It is a good practice to do that to make our code optimizable.

[3:28]So guys, before moving ahead, I would like to share one important thing. Ashi purchased our interview preparation kit, and she is able to crack multiple interviews, and we also referred her in multiple companies. So, uh, let me brief what interview preparation kit is.

[3:43]So actually, we had launched complete interview preparation material, structure step-by-step by myself, expert and MNC's interviewers. And the best part is that no, no one need to go anywhere else to prepare interviews. There is a 99% chance that interview will ask question from this material.

[3:59]So interview preparation kit contain this material, plus one on one lifetime doubts sessions, plus video recorded session for the project enterprise projects and referrals to the big MNCs. So Ashi, can you please provide a feedback like, is it helpful for you?

[4:15]Uh, so yes, as per my experience, whatever questions was there specifically in Springboot, it helped me a lot based on the scenario-based question that is there. It helps a lot during the interviews to answer the questions.

[4:32]Okay, okay, thank you. So guys, uh, I'll provide both links below in the description, interview preparation kit, as well as complete interview preparation material. Now moving to our interview. So, uh, like as you know, uh, there is a annotation Springboot application annotation, right?

[4:47]So it, it consists three annotations internally, right? So can you tell me in brief on this?

[4:54]So there are three annotations, component scan, configuration and enable auto configuration. So what component scan does is basically, it will scan whatever components are needed for our application.

[5:09]Then we have enable auto configuration, which will get all the configurations that are needed. For example, we, we have the database connectivity, which we define in our application.properties. So for example, to get the configurations for that, and then we have enable configuration, that is based on the configurations that we have explicitly defined. So to use that, we can use @enable configuration.

[5:36]Okay, okay. Got it. Uh, have you worked with Spring profiles?

[5:40]Spring profiles, no.

[5:43]Uh, like dev environment, prod environment, testing environment, in your project?

[5:48]No, we have just, uh, we just do the definition in the application properties for the different, different environments. We don't maintain the profiles.

[6:00]Okay, okay. So you guys don't maintain the profile, instead you just, uh, you are just mentioning the environments, uh, in the application properties. So are you using properties or YAML file?

[6:08]Uh, application properties file. Properties. So are you guys planning to migrate to the YAML or not?

[6:14]Yes, because we are planning to do that because, for example, we have deployment.yaml files. So it is very much structured and it helps us to, you know, understand the intention more briefly and more properly.

[6:31]Okay, okay. Correct. Uh, okay. So, uh, do you know about singleton design pattern, Ashi?

[7:09]Yes. So is there any relationship between singleton design pattern and database connection?

[7:16]Yes, so for so what singleton design pattern is, it will maintain one instance. How many times we, we call it, it will always maintain one instance. So in that case, when we are doing a database connectivity, we will always require one instance. We can't have the same database connected two, three times. So that is why we use singleton instance class implementation for database connectivity.

[7:44]Okay. Okay, got it. Uh, okay. And have you worked with transactional annotation?

[7:48]Yes. So basically, what the transactional annotation is, if we are having one process happening, but for due to some reason, the process is stopped or corrupted in between. So the whole thing has to be rolled back. So for that, we use the transactional keyword.

[8:08]Yes, correct. Okay, so tell me one thing, uh, I mean, uh, how would you, uh, okay, no, so tell me a condition like if you are working on transactional annotation, right?

[8:21]And you mentioned the transactional annotation in both class and method level simultaneously. So what issues might arise?

[8:29]So basically, transactional is used on the method level, means the best practice is it to use at the method level. Because for example, if we are updating some resource in our database. So if we are using at the class level, so it won't know that which method is actually had the issue. So that is why it is the best practice to use it at the method level.

[8:54]to use the method level, yeah. So yeah, this is the best practice, but if we, if we add transactional annotation in both class and method level, so method once will override the class level settings. Okay. Yeah, but it would lead some unintended behavior, right? As you already said.

[9:12]Yes.

[9:15]Okay. Uh, okay, got it. Um, okay. So, uh, how would you handle a scenario where a transaction needs to be rolled back due to an operation on a remote service failing?

[9:23]Remote service failing. Uh, yes, I'm not sure about.

[9:29]Okay, okay. So have you heard about compensating transaction or distributed transaction pattern, like Saga?

[9:35]Saga. Yes. Yeah. We can, we could implement Saga pattern here.

[9:41]Okay, okay. Yeah, yeah. Okay. Uh, okay. Got it. Um, okay. So, uh, have you implemented any notification system in a Springboot application?

[9:50]Notification system. No.

[9:53]No. And have you worked with Java email? Uh, no. We have a third party to send the emails and the third party, right? As name suggest you.

[10:03]Okay. Okay. So what third party service, may I know? Uh, so we have this thing called as Gupshup. Yes, so we, uh, that is used, uh, means our application sends the request and the whole body of the message to that.

[10:20]It would be Indian. Uh, third party service, right? Gupshup. Okay. Okay, got it. Um, okay. So, uh, how you guys do deployments in your web applications?

[10:41]So tell me from scratch. So what we do is, we have our deployments done through AWS. So we use the AWS kit only, the code commit and the pipeline. So what we do is, we take the code on our local, we clone the repository, whatever changes we have to do, we do the changes.

[11:02]Then we merge the code, but if there is any conflict during merge, we resolve them first by manually, by the head and the arrows that is there. Based on that, we resolve the conflicts and then we push the code to the pipelines and pipeline deploys the code.

[11:20]What's there in your pipeline? There are there must be few steps in your pipelines, right? Like build check.

[11:28]Uh, yeah. As we have build, then we have image creation, then we have we just have three steps, which is the Yeah.

[11:37]Three steps. Yeah, build and code review. One is the code review.

[11:40]Okay, okay. So, who reviews your code? So we have a T L S that reviews the code first and then.

[11:48]T L S. Yeah.

[11:51]Okay. And who reviews the code of your T L S?

[11:54]T L, that I'm not sure of.

[11:59]Okay, fine. Um, okay, so tell me how Springboot simplifies the web development.

[12:05]So first of all, Springboot is is used to first of all reduce the boilerplate code. Then the annotations make it easier.

[12:20]Then we have the in annotations, for example, we have the autowired annotation, the Springboot application annotation itself, then we have the Spring actuators which helps us to maintain the code and the health of the of the APIs and everything on the production.

[12:36]Then we have the Swagger, uh, Swagger, which helps us to bifurcate our APIs like how what are the APIs, what are the request response.

[12:44]Okay, okay. And it is more easier to maintain a web application using Springboot.

[12:56]Okay. Okay. Got it. So tell me the servers that Springboot provides.

[12:59]Uh, the Springboot have three embedded servers, uh, Tomcat, Undertoe and Jetty.

[13:05]And what's the default one? Tomcat. So can we, uh, I mean remove the default one and include whatever we want?

[13:14]Yes, we can do that. So how can we do that? Uh, we can do that by excluding it through our pom.xml, the Tomcat server.

[13:24]Uh huh. Okay. Got it. Um, okay. So, uh, have you worked with database migration tools like Flyway or Liquibase?

[13:36]No. Okay. So, yeah, just giving you one information, like Springboot provides built-in support for Flyway and Liquibase. They are tools for migrating a database, right? And they have tools they do some automatically initialize and run on application startup.

[13:53]Okay.

[13:57]Okay. Uh, what are actuators in Springboot?

[14:00]So Springboot actuators is basically we use it is it is like a checkup thing. means it is help for us to keep an eye on our Springboot application, how it is managed, how what is the health of the APIs. If any API is running slow, or that information we can gather through actuator.

[14:24]Okay. Got it. Tell me few endpoints, uh, that actuators provide.

[14:29]Uh, one is health. Uh, one is, I think checkup something. I'm not sure of, I'm sure about health.

[14:37]So, have you used health endpoint? Uh, no. No, I haven't.

[14:42]Okay. Have you worked with Springboot data JPA? Yes. What are the advantages Springboot data JPA offer over standard JPA?

[14:50]So first of all, it has the methods which are defined in the JPA, which is like .save, .flush, .find all. So that all helps us not to write the query or not to use the native queries or anything to write our database transactional queries.

[15:16]Okay. So, suppose you have a requirement to dynamically fetch data with variable search criteria. How would you implement it using Spring data JPA?

[15:27]Uh, for searching. Yeah, yeah. If I have to search, uh, I think I can use your the native query. Sorry, the query annotation and then I can just, uh, write the query for it like select the query where condition. If I have to search something, so we will need a where condition.

[15:50]Okay. So do you prefer custom queries or like inbuilt queries?

[15:54]Both have their are According to, yeah, so according to the requirement we should prefer which one has to be.

[16:01]Okay. So tell me where, uh, we must write custom queries, like where we don't have any option for default one. Tell me a scenario.

[16:12]When we have to update something. To update something. Uh, based on some conditions. Yeah, yeah, correct. So that time we can use custom queries.

[16:23]Yeah, yeah. Uh, explain the concept of repository in Spring data JPA.

[16:28]Uh, so repository is basically for doing the database transactions. We have the @repository annotation for that. Now we have different types of repository. We have JPA, we have CRUD repository, we have fetching and sorting repository. So based on the requirement we can use the repository whichever is for our requirement.

[16:54]Okay. And what are the limitations of Spring data repositories? Limitations means disadvantages.

[17:01]Disadvantages, I'm not sure about disadvantages.

[17:07]Okay, there may have disadvantages as well like naming conventions for query methods, which can be confusing and limited in scope for complex queries.

[17:16]Okay. Right? And custom implementations might be necessary for advanced querying. Okay. Okay, got it. So, how do you handle transactions in Spring data JPA?

[17:33]Transaction as in the database transaction? Yeah, yeah, database transactions.

[17:38]Uh, like internally, or?

[17:43]Yeah, yeah, I mean, how could we use transactional annotation here in Spring data JPA?

[17:48]Spring data JPA, I'm not sure about that.

[17:53]Okay, okay. So I think it's the same we already discussed, so we could use transaction annotation. We could add this at method level, class level. We can do the rollback things and all.

[18:04]Okay.

[18:09]Okay. Yeah. Okay. So, uh, if you have a long batch operation, how would you manage transactions to optimize performance and consistency?

[18:18]We can use our caching. One is for enabling the caching because when we are having caching, then it will just, if we store the data, so it will give the same output rather than going to the database and calling the APIs and everything.

[18:36]Yeah, yeah, yeah. And we could also break the whole batch into the segments, right? And we could handle the transactions for each segment.

[18:45]Okay, like if we segregate them into methods and we can just Okay.

[19:02]Yeah. Okay. So, uh, what's the difference between equal and dot equals in Java?

[19:07]Uh, double equal to we use it to compare the references. Dot equals is used to compare the content means if it is string S1 equal to hello, string.

[19:20]Okay. So tell me a scenario where double equal gives a true result and dot equals gives a false result.

[19:25]False. Okay, if it is string S1 equal to hello, string S2 equal to hello. So we compare S1 equal, equal to S2. That time we'll get the same, it has true. But if we write string S1 equal to hello and string S2, string S2 equal to new string, hello, so that times equal will give me true.

[19:54]Okay. Okay. So, how would you handle a situation where you need to compare the content quality of two custom object instances?

[20:01]Content quality.

[20:04]Yeah, yeah, equality. Sorry.

[20:07]Uh, so what to be used? Sorry. Uh, like how would you handle a situation where you need to compare the content equality of two custom object instances, like there are two objects and you have to compare their content, not the reference?

[20:24]We can use dot equals method then. Dot equals method. Okay. Uh, do you know about Java memory model?

[20:32]Java memory, the Java memory management part.

[20:37]Um, no, Java memory model.

[20:40]Model, I'm not sure about.

[20:43]Yeah, so it is abstraction that manages how threads interact through memory and how data is read from and written to main memory.

[20:50]Okay. It is related to thread management. Yeah, yeah, thread management. Okay.

[20:57]Okay. So, tell me the use of final keyword.

[21:02]Uses of final keyword. Okay, so first of all, final keyword is used to make a class immutable. If we declare any variable as final, we we cannot change its value.

[21:13]So it can be used in the immutability of a variable also. So basically, finally, final is used for the implementation of immutability. Okay. Got it. And how can we create immutable class?

[21:30]Uh, first we can declare the class as final. Then second, we can just implement the setter methods, uh, sorry, only the getter methods and not the setter methods. We can declare the variables as final. We can do these things. Okay. Got it. What happens when two different keys have the same hash code?

[22:31]If two different keys have the same hash code. Uh, I think it will give me an exception.

[22:42]No, collision will occur. Okay. Yeah, yeah. So, when two keys have the same hash code, collision will occur. Hashmap stores these keys in the same bucket. Okay. So, what will happen? Before, let me tell you first what will happen before Java 8. All entries in the same bucket were stored in the linked list.

[23:01]But post Java 8, all these entries will be stored in a balance tree. In a more efficient manner. More efficient. Okay. Okay. Um, okay. So, suppose you are storing user session data in a hashmap. How would you ensure thread safety?

[23:18]We can use the synchronized map. Yeah, synchronized map or we can use the concurrent hashmap. Concurrent hashmap. Okay. Correct. Um, so, can you discuss exception handling and what are checked and unchecked exceptions?

[23:36]Okay. So first of all, exception handling is a mechanism to handle errors and the exception that occur in the program. Then we have the checked and unchecked exception. Unchecked exceptions are the runtime exceptions, which can be handled using the throw keyword. Then we have the checked exception, which are the compile time exception. This we can handle using the try-catch block. Okay.

[24:26]Got it. Uh, so, do you know about JUnit test cases?

[24:30]No, I haven't.

[24:34]Okay. So, uh, how you guys are doing test cases and like testing, how you guys are testing your application?

[24:43]Uh, we perform the sanity testing or the unit testing that we do. So we have the document that we have the test cases, based on that we perform the testing for now. We are shifting to it, but it's okay. So I mean, there will be a different team, right? For doing the sanity and all. Okay, okay. Got it. And, uh, do you know about Maven like what Maven is and, uh, why are we using Maven in our project? Why do we use?

[25:16]Okay. So Maven is basically a central repository which has all the dependencies. We use Maven so that whatever dependencies we need, we mention it in our pom.xml file. And then when when we build our code, so that time Maven will first check into our remote repository. If the if the dependencies are present or not, if it is not present, it will download it from the central repository for us.

[25:46]So it makes our work easier. So what's the difference between Maven clean and Maven install?

[25:50]So first of all, Maven clean is used to clean the previous builds that we have had. And Maven install is basically to install and build the whole application again.

[26:02]Okay. Which editor you are using?

[26:05]We use STS. STS. Uh, tell me a few shortcuts that you know about STS.

[26:11]Uh, for when we are debugging the code, that time we can use Control Shift I to know the value of the variables, what the values are assigned to a specific variable. Then we have the Control F to make the code in a proper format. Then we have the Control Click. We do to the method name so that we can reach the method directly rather than processing it through the packages and all.

[26:40]Okay, okay. And which collaboration tool you guys are using?

[26:43]We are using AWS. AWS. Do you know about Git commands? Yes. Okay. So, how do you resolve conflicts?

[26:53]For resolving conflicts, we have to manually resolve them. So there is this process of doing it. So when a conflict occurs, what we have in our code is, we have a head written and the arrows.

[27:06]So whatever is between that, that is our previous code. And the down part, which is in just the arrows, that is our current code. So based on whatever we want to remove or add, we accordingly manage it and then we add it.

[27:22]Okay, okay, got it. What's the difference between Git rebase and Git merge?

[27:30]So when we are merging, when we are merging, for example, two files, so that time the previous histories are also there for them, and the current ones are also there. But when we do Git rebase, it gets on the top of the commit. It doesn't maintain the histories of the previous one. It maintains a linear history, basically.

[28:15]Okay. Okay. Got it. Uh, so, will you be able to solve a coding problem, uh, Ashi?

[28:20]Yeah. Uh, by using Java stream. Okay.

[28:26]Okay. Like, do you know, like, are you in practice?

[28:29]Not that much. Not that much. Normal coding. Yeah.

[28:36]Okay. Um, yeah, okay, please share your screen.

[28:40]Okay. So I will give you few questions, uh, simple questions, okay. Uh, so first question is you are given a string and you have to convert the string into the upper case. All characters of a string should be in upper case.

[29:25]Okay. Mm. Uh, So I will, what I'll do here, I will stream it and then I will use the method reference to use the upper case of the string method.

[29:35]And then I will print it using the for each. Or do one thing. Uh, take a list and enter two, three strings and then convert all those strings into the upper case.

Need another transcript?

Paste any YouTube URL to get a clean transcript in seconds.

Get a Transcript