Deloitte Interview | Java 8 | Spring Boot | Microservices | Cloud | Docker | SQL | NoSQL | 2–7 Years — Transcript
Full transcript
- 0:01Okay, so can you introduce yourself and
- 0:05your recent project briefly? Yeah, hi.
- 0:08So, I have around 3 years of experience
- 0:10in software development and currently
- 0:12I'm working with Accenture. And I have
- 0:15been primarily working in the BFSI
- 0:18domain and focusing on the backend
- 0:20development using the Java Spring Boot
- 0:22and microservices architecture. And in
- 0:24my recent project, I was the part of
- 0:27financial risk monitoring system
- 0:29designed to
- 0:30detect and prevent the suspicious
- 0:33transactions. And the application
- 0:35process
- 0:36this application basically processes the
- 0:38large volumes of transaction data in
- 0:40real time and applies the business rules
- 0:42to identify potential fraud patterns.
- 0:45And my responsibilities basically
- 0:47include in the developing REST APIs,
- 0:49implementing
- 0:51security using the Spring Security and
- 0:53JWT, and also handling the database
- 0:55interaction using the Spring Data JPA,
- 0:58and optimizing the performance for
- 1:00high-throughput scenarios. And along
- 1:03with that, I also work closely with
- 1:05cross-functional teams for requirement
- 1:07analysis, code reviews, and deployment
- 1:11activities, and to ensure the
- 1:13high-quality and scalable solutions. So,
- 1:15yeah, so this is what is all about
- 1:17myself and my recent project.
- 1:19>> Okay, so can you explain the
- 1:22architecture of your project? Yeah,
- 1:25sure. So, in my project, like we
- 1:27followed a microservices architecture in
- 1:30instead of a monolithic approach. So,
- 1:31because it gives like better scalability
- 1:34and flexibility.
- 1:35>> [snorts]
- 1:35>> So, that is why we used a microservices.
- 1:38And the application was basically
- 1:40divided into multiple small services
- 1:42like we had transaction service layer,
- 1:45and then user service, then risk
- 1:48analysis service,
- 1:49and also there were multiple other
- 1:51services as well. And each service was
- 1:53independently deployable. So, we had an
- 1:55API gateway at the entry point and that
- 1:58basically handled the request routing
- 2:00and authentication and basic validations
- 2:02as well before forwarding the request to
- 2:04the respective microservices. And uh
- 2:08for communication between the services,
- 2:10we mostly used REST APIs for uh
- 2:13synchronous calls. And in some cases, we
- 2:15used asynchronous messaging to handle
- 2:18heavy or background processing so that
- 2:21the system remains responsive. And each
- 2:24microservices had its own database to
- 2:26maintain loose coupling. And we mainly
- 2:29also used a
- 2:31relational databases like MySQL for
- 2:34storing the structured data such as like
- 2:37transactional and user details. So,
- 2:39yeah, so this design basically helped us
- 2:41to like make the things more scalable
- 2:44and dual services and load and also made
- 2:47the system easier to maintain and
- 2:49enhance. So, yeah. Okay, so can you tell
- 2:52me why did you choose microservices over
- 2:56the monolithic architecture? Yeah, so in
- 2:59our case, the system had like multiple
- 3:02functionalities like transaction
- 3:03processing, user management, and risk
- 3:05analysis and all as I told you. So,
- 3:08using microservices like that actually
- 3:11made it easier to split these into the
- 3:14independent services. And this basically
- 3:17helped us to scale only the required
- 3:20part instead of the whole application.
- 3:24So, also the deployment became like kind
- 3:27of easier because the changes in one
- 3:30service did not impact the entire
- 3:32system. So, that basically usually a
- 3:35problem
- 3:36it was a problem in the
- 3:38multi-architecture.
- 3:39So, that is the reason why we thought to
- 3:42use microservices. So, yeah.
- 3:44>> Okay, fine.
- 3:46And how does your API gateway work and
- 3:51which one did you use? Can you tell me?
- 3:53Yeah, so basically we used Spring Cloud
- 3:57Gateway
- 3:58as our API gateway. So, it acts as a
- 4:04single entry point for all client
- 4:06requests. And it basically handles the
- 4:09routing the request to the correct
- 4:11microservices. And also applies the
- 4:14filters like authentication, logging,
- 4:16and request validation.
- 4:18So, instead of exposing all services
- 4:21directly, like everything goes through
- 4:25the gateway. So, that basically
- 4:26ultimately improves the security and
- 4:28control.
- 4:29So, that's that is how we used the API
- 4:32gateway. Okay, so can you tell me the
- 4:35full API request flow? How it flows from
- 4:39starting to end? Yeah, sure. So, in my
- 4:42project, like
- 4:44wherever a client sends a request, for
- 4:46example, through Postman or from the
- 4:49front end, then it first reaches the API
- 4:51gateway where all basic validations and
- 4:54authentication checks are applied. And
- 4:56after that, the request is forwarded to
- 4:59the respective microservices and enters
- 5:02the Spring Boot application through the
- 5:04dispatcher servlet.
- 5:06So, that basically acts as the front
- 5:08controller. And from there, it passes
- 5:11through the chain of filters.
- 5:13So, especially the Spring Security
- 5:15filters and all. So, where
- 5:17authentication and authorization are
- 5:18handled using the JWT tokens.
- 5:21So, [snorts] once the request is
- 5:23validated, then it reaches the
- 5:26controller layer and that basically maps
- 5:28the incoming request to the appropriate
- 5:31endpoint.
- 5:32So, the controller has like then like
- 5:36delegates the request to the service
- 5:38layer. And there the actual like we can
- 5:42see the all business logic is written.
- 5:44And the service layer basically after
- 5:47that interacts with the repository layer
- 5:49to perform the database operations using
- 5:51the JPA or Hibernate, whatever we are
- 5:53using.
- 5:54So, after processing, the response flows
- 5:57back again from the repository to the
- 6:00service and to the controller there, and
- 6:03finally it is sent back to the client as
- 6:05HTTP response.
- 6:06So, in the response, it can be like JSON
- 6:08or XML, whatever the format we have.
- 6:10Though usually we are using JSON one.
- 6:12So, in the JSON format, it will be sent.
- 6:14So, this is how the whole flows like
- 6:17works from request to controller,
- 6:20service layer, and then repository,
- 6:22again database, and again back to the
- 6:25whatever request we had sent. So,
- 6:27yeah, so that is how it works. Okay, can
- 6:30you tell me
- 6:32where exactly does Spring Security come
- 6:35into the flow?
- 6:37Like before dispatcher servlet or after?
- 6:40Yeah, so in the request flow, like
- 6:43Spring Security actually comes into play
- 6:46before the request reaches the
- 6:48dispatcher servlet. So, it works through
- 6:50a chain of filters which are part of the
- 6:55servlet filter mechanism. So, when a
- 6:57request comes in, it first goes through
- 7:00the like these security filters where
- 7:02authentication and authorization checks
- 7:04are performed. So, for example, like
- 7:06validating the JWT token. If the request
- 7:09is valid, then only then it is allowed
- 7:12to the to proceed further to the
- 7:14dispatcher servlet and eventually to the
- 7:17controller. So, like if authentication
- 7:20fails, then the request is blocked at
- 7:22the filter level itself. And like we
- 7:25have multiple error
- 7:27like responses like 401 or 403. So, that
- 7:31is returned. And like it never basically
- 7:33reaches to the controller. So, yeah, so
- 7:35that is how we implement this Spring
- 7:37Security. Okay, so can you tell me how
- 7:40does Spring decides like which
- 7:43controller method to call? Yeah, sure.
- 7:45So, Spring decides like which controller
- 7:48method to call based on the request
- 7:49mapping defined in the controller
- 7:51classes. So, basically there the request
- 7:54reaches the dispatcher servlet and it
- 7:56looks at the like in the URL, whatever
- 7:59URL we give. So, it looks at the URL and
- 8:02HTTP methods like get, post, or any
- 8:06other, and then it matches it with the
- 8:08mapping
- 8:10and define using the we we will be
- 8:13having the annotations like at the rate
- 8:15of request mapping, get mapping, post
- 8:17mapping, and all in the controller
- 8:19class. And these mappings are handled by
- 8:21something called like handler mapping
- 8:23internally. And that basically feels the
- 8:27correct
- 8:28controller and method that matches the
- 8:30request path and method type. And once
- 8:33the correct method is identified, then
- 8:36Spring invokes that method and also um
- 8:39takes care of binding the request data
- 8:41like JSON body or query parameter and
- 8:45all to the method argument
- 8:47automatically.
- 8:48So, yeah, so that is how Spring decides
- 8:51like which controller method to call.
- 8:53Yeah. Okay, so can you tell me where
- 8:55filters come into picture?
- 8:58And also can a request reach controller
- 9:01without passing the filter? Do you Do we
- 9:04have any option like that? Actually,
- 9:07filters comes into picture right at the
- 9:10very beginning of the request life
- 9:12cycle. So, even before the request reach
- 9:14to the dispatcher servlet, then itself
- 9:17the filter is executed. And they are the
- 9:19part of servlet container and and
- 9:23like form a filter chain through which
- 9:26like every incoming request must pass.
- 9:29Okay, so we cannot bypass it actually.
- 9:31So, this is where the things like
- 9:33authentication, authorization, logging,
- 9:35and request validations are handled. And
- 9:38especially in a Spring Security. So,
- 9:40particularly a request cannot reach the
- 9:43controller without going through the
- 9:46filters. So, it may filter like
- 9:49if suppose if any filter blocks the
- 9:52request, so for example, due to failed
- 9:53authentication or something, then the
- 9:55flow stops there itself and the is never
- 9:58reached. So, that is how this whole flow
- 10:01works. And what about the exception
- 10:04handling? So, where does this exception
- 10:06handling happens in the flow? Yeah, so
- 10:09like in the like whole flow like
- 10:11exception handling usually happens after
- 10:14the request reaches the controller or
- 10:17service layer, and something goes wrong
- 10:19during the processing. So, instead of
- 10:21handling exceptions in
- 10:24every controller method, we usually like
- 10:27generally use a global exception handler
- 10:29like we have at the rate of controller
- 10:31advice. So, that we use, and this allows
- 10:34us to catch like any kind of different
- 10:36types of exceptions in a centralized
- 10:39place and return a proper consistent
- 10:41HTTP responses like we have 404 or like
- 10:44400 or 500, whatever it may be. So, with
- 10:46a meaningful message actually.
- 10:48So, we do that way. And so, if any
- 10:51exception is thrown in the controller or
- 10:53service layer, then it gets inter-
- 10:55cepted by the global exception handler
- 10:56before the response is sent back to the
- 10:58client. So, that is how this global
- 11:01exception handling works. Yeah. Okay,
- 11:02have you heard of interceptor, or can
- 11:05you tell me what is the difference
- 11:06between filter and interceptor? Yeah,
- 11:09like the main difference between filter
- 11:11and interceptor is where they are used
- 11:14and what level they operate on, okay?
- 11:18So, filters [snorts]
- 11:19are part of servlet container
- 11:21and work at the lower level. So, they
- 11:25are executed before the request reaches
- 11:28to the servlet reaches servlet, okay?
- 11:30And they are mainly used for things like
- 11:32authentication, logging, or modifying
- 11:34the request. Okay, and they also apply
- 11:38to all types of requests. So, not just
- 11:41like a Spring specific request. So, it
- 11:42is a like kind of general thing, okay?
- 11:45So,
- 11:46on the other hand, interceptors are like
- 11:48the part of a Spring framework and work
- 11:51at the Spring MVC level only, okay? So,
- 11:53they come into picture after the
- 11:56dispatcher servlet is there, and but
- 11:58before the controller method is
- 12:00executed. So, they come there, okay? So,
- 12:02interceptors are basically like more
- 12:04suited for the task like pre-processing
- 12:07and post-processing around the
- 12:09controller logic. And such as adding
- 12:12models attributes and or handling
- 12:14authorization checks and specific to the
- 12:17controller methods. So, there we use
- 12:19more for this, yeah. Okay, so can you
- 12:21tell me where does serialization and
- 12:24deserialization
- 12:25>> happen? Yeah, serialization and
- 12:26deserialization mainly happen at the
- 12:28controller layer in the Spring Boot
- 12:30application. So, when a client sends the
- 12:33request with a JSON body, then a Spring
- 12:36automatically converts that JSON into
- 12:38Java object before passing it to the
- 12:41controller method. And this basically
- 12:44processes is like this process basically
- 12:47called is the deserialization. So,
- 12:48similarly, when the controller returns
- 12:50the respective response object, and the
- 12:52Spring converts that Java object back to
- 12:55the JSON
- 12:56before sending it to the client. So,
- 13:00like
- 13:01then this basically this process is
- 13:02called the serialization. So, this is
- 13:04basically handled internally by the HTTP
- 13:07message converters, and by default
- 13:09Spring uses the like we have the I think
- 13:12Jackson library is there. So, that is
- 13:14used to perform these conversions, okay?
- 13:16So, we usually don't need to write any
- 13:19manual code for this, and it
- 13:21automatically converts
- 13:23to the JSON, yeah. Okay, so can you tell
- 13:25me
- 13:27what is the difference between
- 13:29authentication and authorization? Yeah,
- 13:32authentication and authorization are
- 13:34like two different steps in the security
- 13:36processes. So, authentication is about
- 13:39like
- 13:39verifying like who is the user, okay?
- 13:43So, typically by checking the
- 13:45credentials like username and password
- 13:47during the login, so we can identify if
- 13:50the these credentials are correct or
- 13:52not. So, this is basically called the
- 13:54authentication. And once the user is
- 13:56authenticated, then authorization comes
- 13:58into picture. So, that basically
- 14:00determines what like that user is
- 14:04allowed to access or perform in the
- 14:06system, okay? So, for example, after
- 14:08logging like a normal user might have
- 14:11access to like basic features, while an
- 14:14admin user can like access additional
- 14:17functionalities based on their roles and
- 14:19permissions, okay? So, yeah, so that's
- 14:21the main difference between these two
- 14:23like authentication and authorization.
- 14:25Okay, so can you tell me what is auto
- 14:28configuration in Spring Boot? Yeah, auto
- 14:30configuration basically means like the
- 14:32Spring Boot automatically configures the
- 14:35application based on the dependencies
- 14:38present in the class path.
- 14:40So, for example, if we add a web
- 14:42dependency, then it automatically sets
- 14:44up the things like dispatcher servlet
- 14:47and like embedded server.
- 14:49So, this basically reduces the manual
- 14:51configuration and makes the development
- 14:53faster.
- 14:54So, yeah, so that's what is the auto
- 14:56configuration in Spring Boot, yeah.
- 14:58Okay, and what is the difference between
- 15:00component, service, and repository
- 15:03annotation? Yeah, so
- 15:04this component, service, and repository
- 15:06like all three are the stereotype
- 15:08annotation, and it is used for component
- 15:11scanning, but they have different
- 15:13purposes. So, at component is a generic
- 15:16annotation, and at service is used for
- 15:18the service layer, like where the
- 15:21business logic is written. And at
- 15:24repository is used for the data access
- 15:26layer, okay? And also like at the rate
- 15:28of repository provides the additional
- 15:30benefits like exception
- 15:32like
- 15:33translation for the database operations
- 15:35and all.
- 15:36So, yeah, so that's what are the these
- 15:39annotations, yeah. And what is
- 15:40dependency injection?
- 15:43Yeah, dependency injection is a design
- 15:45pattern we can say like where objects
- 15:48are provided with their dependencies
- 15:50instead of the creating them manually,
- 15:53okay? So, in a Spring like this is
- 15:56managed by the container, and like that
- 15:59basically helps in loose coupling and
- 16:02like easier testing,
- 16:04okay? So, we usually use like
- 16:08constructor injection as like it is more
- 16:10recommended, and it makes the code like
- 16:14more maintainable, yeah. Okay, so
- 16:17as you said that constructor injection
- 16:19is more recommended, so can you tell me
- 16:22why?
- 16:23>> Yeah, so constructor injection is
- 16:25generally more recommended because like
- 16:27it makes the
- 16:29dependencies of a class explicit and
- 16:32ensures that the object is always
- 16:34created in a valid state, okay? So, when
- 16:37we use constructor injection, then all
- 16:39required dependencies are provided at
- 16:42the time of the object creation. So,
- 16:45there is no chance of having null or
- 16:47like uninitialized fields later on,
- 16:50okay? So, like it also promotes like you
- 16:54can say immutability, okay? So, because
- 16:56we can mark the dependencies as final,
- 17:00so that basically improves the code
- 17:02safety and clarity. So, like another
- 17:05advantage we can say is like that it
- 17:07makes the classes like easier to test,
- 17:11and since we can directly pass mock uh
- 17:15dependencies through the constructor
- 17:17without relying on the Spring container,
- 17:21so overall like
- 17:23it leads to cleaner and more
- 17:25maintainable code. So, yeah. Okay, so
- 17:28can you tell me what is the difference
- 17:30between at controller and
- 17:33at the rate of rest controller? At
- 17:36controller and rest controller like
- 17:38the main difference in between these two
- 17:40is how they handle the response
- 17:42actually. So, at controller is typically
- 17:45used in traditional Spring MVC
- 17:47application where we
- 17:49return like views like JSP or HTML
- 17:54pages,
- 17:55and in this case the method usually
- 17:57returns the view name, and the view
- 18:00resolver maps it to the actual UI page.
- 18:04So, if we want to return data instead of
- 18:06view, then we have to use at the rate of
- 18:09response body on the method side, okay?
- 18:12And on the other hand like if on the
- 18:15other hand at the rate of rest
- 18:16controller is specially designed for the
- 18:18rest APIs where we directly return data
- 18:21in in the form of JSON or XML. So, yeah,
- 18:25so this is basically the combination of
- 18:28at controller and response body. So,
- 18:30that is what is the at the rate of rest
- 18:32controller. So, every method
- 18:34automatically returns the response
- 18:37body instead of the view. So, because of
- 18:39this for back-end services or
- 18:42microservices, we mostly use at the rate
- 18:45of rest controller as it simplifies like
- 18:49development and avoids the need to add
- 18:52like at the rate of response body on
- 18:54each method. So, yeah, so that's the
- 18:55difference between these two, yeah.
- 18:57Okay, so what is a Spring Data JPA?
- 19:01Yeah, Spring Data JPA is used to
- 19:03simplify database operations in a Spring
- 19:06Boot applications. So, instead of
- 19:09writing a lot of boilerplate code for
- 19:12CRUD operations, we can directly use
- 19:14repository interfaces like JPA
- 19:16repository.
- 19:18So, that is already like provide that
- 19:21already provide methods like save, find,
- 19:23delete, and all. So, it also supports
- 19:26the writing custom queries using the
- 19:29method naming conventions or like JPQL
- 19:32if required. So, internally it uses the
- 19:35Hibernate
- 19:36as the ORM tool to map Java objects to
- 19:40database tables. Yeah, so that is what
- 19:42is the Spring Data JPA, and it overall
- 19:45reduce the basically the development
- 19:48effort, and it improves the readability,
- 19:51and
- 19:52kinds of let's let's us focus more on
- 19:55the business logic rather than the
- 19:57database handling. So, yeah. Okay, and
- 20:00what is Eureka server in microservices?
- 20:03Yeah, Eureka server is used for the
- 20:06service discovery in microservices
- 20:08architecture. So, all the microservices
- 20:11register themselves with the Eureka
- 20:13server when they start and like when
- 20:17they have to send the like kind of
- 20:19heartbeat signals to indicate like they
- 20:21are alive. Okay, so other services can
- 20:25then discover these
- 20:27services using their names instead of
- 20:31hard coding IP addresses or URLs. So,
- 20:34this basically makes the system like
- 20:36kind of more flexible and especially
- 20:38when the services like scale up or down
- 20:41dynamically. Yeah, so that's what is the
- 20:43Eureka server in microservices. And what
- 20:46is circuit breaker in microservices?
- 20:49Yeah, circuit breaker is a design
- 20:50pattern used to handle failures between
- 20:53the
- 20:54microservices and prevent the cascading
- 20:58failures. And if one service is down or
- 21:02responding slowly, then the circuit
- 21:04breaker stops sending the request to
- 21:07that service after a certain threshold
- 21:09and like immediately returns the
- 21:11fallback response. Okay, so this
- 21:13basically helps in maintaining system
- 21:15like like system stability and prevents
- 21:18the entire system from getting impacted
- 21:21due to the
- 21:22like one single failing service. Okay,
- 21:25so once the service becomes healthy
- 21:27again, then the circuit breaker allows
- 21:29request to pass through again. Okay,
- 21:31yeah, so commonly tools we use for this
- 21:34is like resilience for J. So, that is
- 21:38mostly I have used to like implement
- 21:40this. Yeah. Okay, and what is Feign
- 21:42client?
- 21:43>> Yeah, Feign client is a like we can say
- 21:45declarative REST client
- 21:48that provided by the Spring Cloud and it
- 21:50makes the communication between
- 21:52microservices like much more easier.
- 21:54Okay, so instead of writing like manual
- 21:57HTTP calls and using REST template or
- 22:00like a web client, we can simply define
- 22:03an interface and annotate it with the
- 22:06like at the rate of Feign client and
- 22:08Spring automatically generates the
- 22:10implementation. Okay, so like it
- 22:13integrates well with service discovery.
- 22:16So, we can call services using their
- 22:19names instead of like URLs. Okay, so we
- 22:22don't have to use URLs in this case. So,
- 22:25ultimately this makes the code more
- 22:26cleaner and more readable and easier to
- 22:29maintain. So, that is what is the Feign
- 22:31client is. Yeah. Okay, and what is
- 22:33Docker and how do you use it in
- 22:36microservices? Yeah, Docker is a
- 22:38containerization tool. Okay, so that
- 22:41allows us to package an application
- 22:44along with all its dependencies into a
- 22:46container. So, like it can run
- 22:49consistently across different
- 22:51environments. So, yeah, that is what is
- 22:53the Docker and in microservices
- 22:54architecture like each service can be
- 22:57like containerized separately and
- 23:00deployed independently. Okay, so this
- 23:03basically makes the like deployment much
- 23:05more faster and more reliable and also
- 23:08helps in a scaling services easily. So,
- 23:11yeah, so Docker like
- 23:13we can say also works well with the
- 23:15orchestration tools like
- 23:17we have Kubernetes, right? So, we we use
- 23:20along with that and that basically helps
- 23:22in managing multiple container in
- 23:24production environments. So, that is
- 23:26what is the Docker. Yeah. Okay, so can
- 23:28you tell me how do you handle null
- 23:32values safely? Maybe how many ways are
- 23:34there? Yeah, so like in my project I
- 23:37handled the null values like there are
- 23:40few standard ways to avoid runtime
- 23:42issues like null pointer exception and
- 23:44all. So, first of all, I can like we can
- 23:47use proper null checks before
- 23:50like accessing any object especially
- 23:53when dealing with
- 23:55external inputs or database responses.
- 23:58So, in cases where null can lead to
- 24:02exceptions, we can use try catch blocks
- 24:05to handle them like and return
- 24:08meaningful errors
- 24:10error message instead of like breaking
- 24:12the whole application. And also like
- 24:15wherever possible, we can use optional
- 24:17class which has been introduced in Java
- 24:208.
- 24:20So, that basically helps in handling
- 24:23null values in a more clean and
- 24:26readable way by forcing
- 24:29us to explicitly deal the absence of the
- 24:32value instead of the directly accessing
- 24:34it. So, yeah, so these are the I think
- 24:36the approaches mostly I use to handle
- 24:39the null values safely. Yeah. Okay, so
- 24:42what are the other features of Java 8
- 24:46you know? Yeah, so there are various
- 24:49features of Java 8 as are there like
- 24:52one of the main feature is like lambda
- 24:54expression.
- 24:55So, basically that allows us to write
- 24:57shorter and cleaner code especially when
- 25:00working with collections. Along with
- 25:02that, the functional interfaces has been
- 25:05introduced. So, like which have only one
- 25:08abstract method and mainly used with the
- 25:10lambda expressions. And apart from that,
- 25:13we have a stream APIs and then we have
- 25:16the like various filters are there. Like
- 25:19we can use filters, maps and reduce. All
- 25:22that we can use along with this stream.
- 25:24And Java 8 also introduced the optional
- 25:27classes to handle so which like we
- 25:29already discussed and
- 25:32there were also like enhancements in
- 25:34interfaces where default and static
- 25:36methods were added. So, we can provide
- 25:38methods implementations inside the
- 25:40interfaces without breaking the existing
- 25:43code. Okay, and
- 25:45apart from that, the new date time API
- 25:47has been introduced. So, that is also
- 25:49one of the
- 25:50major enhancement. So, yeah, so these
- 25:53are the various
- 25:54features of the Java 8 are there. Okay,
- 25:57so how this date time API is better
- 26:00compared to the older versions of Java?
- 26:03Yeah, the Java 8 date time API is much
- 26:06better compared to older versions
- 26:07because it mainly it fixes the lots of
- 26:11problems that were there in the classes
- 26:13like date and calendar which were
- 26:15earlier used. So, earlier APIs were not
- 26:18thread safe. So, that means that if
- 26:20multiple threads were using them, it
- 26:23could lead to unexpected issues at that
- 26:25time. But the new API which comes under
- 26:28the java.time package so that is
- 26:31basically immutable and thread safe. So,
- 26:33it works like much better in the
- 26:36multi-threaded environments. And another
- 26:38improvement is that the old API was
- 26:41confusing and not very like kind of
- 26:43intuitive. So, for example, months were
- 26:46like zero based and months were not
- 26:48clearly named. So, in Java 8 like
- 26:51classes like local date and local time
- 26:53and local date time and all are there.
- 26:55So, that are much more clear and easy to
- 26:58use. Okay, and also handling the time
- 27:00zones was very difficult earlier. But
- 27:03now like this classes like zone date
- 27:07time has become like much more simpler.
- 27:09So, yeah, so formatting and passing
- 27:10dates is now much more better now using
- 27:13like this date time formatter. So, that
- 27:16basically is more flexible and thread
- 27:18safe compared to the older
- 27:21simple date format. Yeah, so overall the
- 27:24new date time like is more readable we
- 27:27can say and less error prone and
- 27:29performs much much better in
- 27:31like multi-threaded environment. Okay,
- 27:32can you tell me why is string is
- 27:34immutable? Yeah, so a string is
- 27:37immutable in Java because like basically
- 27:39it cannot be changed. So, once it is
- 27:41created, it cannot be changed. So, that
- 27:43is why we say that it is immutable. So,
- 27:45this design basically provides the
- 27:46multiple benefits
- 27:49to our our programming. So, for example,
- 27:52uh
- 27:53security
- 27:54and
- 27:55then performance. So, security because
- 27:57like since the strings are widely used
- 27:59in sensitive areas like paths and
- 28:01databases connections and all. So, like
- 28:03using this immutable string is kind of
- 28:06it provides the I mean good security to
- 28:08that. And it also improves the
- 28:10performance because the strings can be
- 28:12cached in a string pool and reused. So,
- 28:15yeah, so that is why it is like enhances
- 28:17the performance. And apart from that,
- 28:20additionally immutability makes the
- 28:22string thread safe. So, multiple threads
- 28:24can use them without synchronization.
- 28:26So, yeah, so that is why string is
- 28:28immutable. Okay, and what is the
- 28:29difference between array list and linked
- 28:31list? So,
- 28:34array list is based on the dynamic
- 28:35array. So, it provides the fast random
- 28:37access using the indexes. But insertion
- 28:40or deletion in the middle
- 28:42can be like slow because the elements
- 28:44need to be shifted. Okay, so that is
- 28:47what is about the array list. And linked
- 28:49list on the other hand a doubly linked
- 28:51list like a structure internally. So,
- 28:53insertion and deletions are faster
- 28:55especially in the middle. But accessing
- 28:57the elements takes more time because the
- 29:00whenever we try to access, then the
- 29:02traversal is traversal is required.
- 29:04Okay, so the choice basically depends on
- 29:06the use case like
- 29:08if it is read heavy or modification
- 29:10heavy. So, based on that, we decide like
- 29:12which one we have to use like array list
- 29:14or linked list.
- 29:16Yeah. Okay, and what is hash map and how
- 29:18it works internally in very brief can
- 29:21you tell me like what is the complexity
- 29:24and all? So, hash map basically stores
- 29:26the data in key value pairs and
- 29:30internally uses an arrays of buckets.
- 29:33So, when a key is inserted, its hash
- 29:36code is calculated and converted into an
- 29:39index where the entry will be stored.
- 29:42Okay, so if multiple keys map to the
- 29:44same bucket, so collision
- 29:47handling is done using a linked list or
- 29:50tree structure in Java 8. Okay? So,
- 29:53during retrieval, hash code is used
- 29:55again to find the bucket and then equals
- 29:58is used to find the extra key. So, this
- 30:00overall this makes the hash map like
- 30:02very efficient and
- 30:04its complexity will be like O of 1.
- 30:07Okay. And what is hash code and equals
- 30:10contract?
- 30:12Yeah, the
- 30:13contract states that if two objects are
- 30:17equal using equals method, then their
- 30:20hash [snorts] code must be the same.
- 30:22Okay? However, if two objects have the
- 30:25same hash code, then they are not
- 30:27necessarily equal. Okay? So, this
- 30:30contract is important because the hash
- 30:33based collections like hash map rely on
- 30:35its for like storing and retrieving
- 30:38objects correctly. Okay? So, if this
- 30:41contract is violated, then it can lead
- 30:43to incorrect behavior or data loss.
- 30:46Okay? So, that is what is the hash code
- 30:48and equals Okay. And what is the
- 30:49difference between
- 30:51hash map and concurrent hash map? Yeah,
- 30:53hash map is not thread safe. Okay? So,
- 30:56if multiple threads access it
- 30:58simultaneously, then it can lead to like
- 31:01inconsistent data. Okay? But concurrent
- 31:04hash map is designed for concurrent
- 31:07environments and it allows multiple
- 31:09threads to read and write safely. So,
- 31:12yeah. So, instead of locking the entire
- 31:15map, it uses the segment level or bucket
- 31:18level locking. So, that basically
- 31:19improves the performance compared to the
- 31:22synchronized maps.
- 31:23So, yeah. So, that is the difference
- 31:24between hash map and concurrent hash
- 31:26map. Okay. And what is fail fast and
- 31:30fail safe? Yeah, fail fast iterators
- 31:32like immediately throw concurrent
- 31:34modification exception if the collection
- 31:36is modified during the iteration.
- 31:38Basically, this is done to avoid the
- 31:40inconsistent behavior. So, fail fast
- 31:42iterators
- 31:43like on the other hand like it works on
- 31:46the copy of the collection and do not
- 31:47throw like any kind of exception because
- 31:49we create the copy and any kind of
- 31:51modification in while iterating that it
- 31:53does not throw any exception. Okay? So,
- 31:57but the problem is that we may not
- 32:00like see the latest changes in that in
- 32:02that case.
- 32:03Okay? But the but it will not throw any
- 32:06kind of exception. So, for example, we
- 32:08have array list. So, that is fail fast
- 32:09and then we have a concurrent hash map
- 32:12or copy on write array list. So, all of
- 32:15them are like fail safe. Okay? So,
- 32:17because they work on the copy of the
- 32:19object. Okay. And what is
- 32:21synchronization? Synchronization is used
- 32:24to control access to shared resources by
- 32:29multiple threads. So, it ensures that
- 32:31only one thread can execute
- 32:34critical section at a time that
- 32:36preventing prevents the data
- 32:38inconsistency. So, it can be applied at
- 32:41method level or block level, but
- 32:43excessive synchronization can reduce
- 32:45performance.
- 32:46So, yeah. So, that is what is the
- 32:48synchronization. And what is volatile
- 32:49keyword?
- 32:51Yeah, volatile basically ensures that
- 32:53the
- 32:54value of a variable is always read from
- 32:58the
- 32:59main memory, not from the thread cache.
- 33:02Okay? So, this ultimately guarantees
- 33:05like visibility of changes across the
- 33:07threads.
- 33:08But it does not provide the auto
- 33:10atomicity. So, it cannot be replaced
- 33:13it cannot replace synchronization
- 33:14completely, but yeah, we use for the for
- 33:17the visibility of the changes across the
- 33:18threads. Yeah.
- 33:19>> And what is class loader? Class loader.
- 33:21Yeah, class loader is responsible for
- 33:23loading classes into memory at run time.
- 33:25So, basically it follows a hierarchical
- 33:26design model with like bootstrap,
- 33:30extension and application class loader.
- 33:31So, that basically ensures that the
- 33:34security and avoids the duplicate class
- 33:36loading.
- 33:37So, that is what is the class loading.
- 33:39Yeah. And
- 33:40what is the difference between interface
- 33:43and abstract class in very brief? Yeah,
- 33:45interface is used for abstraction and
- 33:48supports multiple inheritance. While
- 33:51abstract class can have both abstract
- 33:53and concurrent methods and supports
- 33:55single inheritance. Okay? So, like
- 33:57interfaces are more flexible especially
- 34:00after Java 8 with the default methods.
- 34:03So,
- 34:04yeah. So, basically this is the
- 34:05difference like being very brief. And do
- 34:07you know marker interface?
- 34:10Yeah, marker interface is an empty
- 34:12interface we can say. So, that is used
- 34:14to indicate some special behavior to JVM
- 34:17or framework.
- 34:19So, for example, like serializable tells
- 34:22JVM that the object can be serialized.
- 34:24So, it is just like empty interface we
- 34:27can say. But yeah, that is for the
- 34:28notation like
- 34:30how the work of any like annotation we
- 34:33are going to use. Okay. So, in SQL, can
- 34:35you tell me what is the difference
- 34:37between SQL and NoSQL databases? Yeah.
- 34:40So, SQL databases are like relational
- 34:43databases that store data in structured
- 34:47tables with rows and columns. So, they
- 34:49follow a fixed schema meaning that the
- 34:52structure of the data must be defined
- 34:55before inserting data.
- 34:57So, that is what is that and examples
- 34:59like we have MySQL, PostgreSQL, Oracle.
- 35:02So, all these are the SQLs. Okay?
- 35:05So, like they are best suited for the
- 35:07applications where data consistency and
- 35:10relationships are important like banking
- 35:12system and all. Okay? On the other hand,
- 35:14NoSQL databases are non-relational and
- 35:17provide flexible schemas. So, they can
- 35:20store data in formats like key-value and
- 35:23document, column or paragraph. So, in
- 35:26this case examples we have like MongoDB,
- 35:29Cassandra, Redis. So, all these are
- 35:31examples of it. So, [snorts] they are
- 35:33designed for scalability and handling
- 35:35large volumes of
- 35:38unstructured or semi-structured data.
- 35:40So, that makes them suitable for the
- 35:41real-time application and big data
- 35:43system. So,
- 35:44So, that's the difference between these
- 35:46two. Do you know what is normalization
- 35:48and denormalization
- 35:50and why we use it? Yeah. So,
- 35:52normalization is the process of
- 35:54organizing the data in a database to
- 35:57reduce the redundancy and improve the
- 35:59data like integrity. And it involves the
- 36:03dividing large table into smaller ones
- 36:07and defining relations between them.
- 36:09Okay? So, this basically ensures that
- 36:12the data is stored only once and avoids
- 36:15duplication. So, that's what is the
- 36:17normalization. So, basically we have
- 36:18there are different types of normal
- 36:20forms like I think 1NF, 2NF, 3NF and
- 36:23all. So, each with have the specific
- 36:26rules. For example, 1NF removes the
- 36:28repeating groups. Okay? And 2NF like
- 36:31removes the particular dependencies and
- 36:333NF removes the like transitive
- 36:35dependencies. Okay? So, yeah. So, that
- 36:37is what is the normalization and like
- 36:39its various forms. And the
- 36:41denormalization?
- 36:42>> Yeah, again denormalization is a process
- 36:44of combining tables to reduce the number
- 36:47of joins and
- 36:48improve the query performance. Okay? So,
- 36:51it intentionally introduces the
- 36:54redundancy into the database for the
- 36:56faster read operations. So, that is what
- 36:59is the denormalization. So, it is
- 37:01commonly used in reporting system or
- 37:05data warehouse where the read operation
- 37:08is kind of more important than the write
- 37:10efficiency. Yeah. So, however, it like
- 37:11it can lead to data inconsistency if not
- 37:14managed properly, but yeah, that is what
- 37:16is the purpose of denormalization. And
- 37:18what is indexing and why it is used?
- 37:21>> Yeah, indexing is used to improve the
- 37:23like speed of the data retrieval in a
- 37:26databases. So, it works like an index in
- 37:30a book we can say. So, like it allows
- 37:33the database to quickly locate rows
- 37:36without scanning the entire table. So,
- 37:38that is what is the indexing.
- 37:40So, like however, like indexes
- 37:44like come with a trade-off. So, like
- 37:46while they improve the read performance,
- 37:48they can also slow down the write
- 37:50operations because we need more memory
- 37:52to I mean convert the whole database
- 37:56like into the form so that the indexing
- 37:59can be applied on top of that. Any
- 38:01select query we are writing. So, it
- 38:02basically it will like kind of divide
- 38:04the whole like we have dictionary like
- 38:07right? So, if suppose we have to see any
- 38:10search with the A, we can directly go
- 38:12with
- 38:13a like from which page number to which
- 38:14to page number A is there. So, and which
- 38:17page number to which page number B is
- 38:19there. So, similarly in case of indexing
- 38:21also, we have the similar concept like
- 38:25and but because of that, we have we need
- 38:27extra memory. So, that is why the write
- 38:29up becomes the bit bit slower, but yeah,
- 38:32the read be be become the faster. And
- 38:33what is the difference between delete,
- 38:35truncate and drop? Yeah. So, delete
- 38:37removes the specific rows based on the
- 38:40condition and it can be rolled back. So,
- 38:42that is the delete. And truncate
- 38:44basically removes all rows from the
- 38:46table quickly and can't be rolled back.
- 38:48Okay?
- 38:49And drop basically completely deletes
- 38:51the table structure along with its data.
- 38:53So, that is the drop.
- 38:55So, that's the major difference between
- 38:56these three.
- 38:57>> Do you know what is sharding? Yeah,
- 38:58sharding is a technique used to like
- 39:02distribute data across the multiple
- 39:04servers. So, each shard like contains a
- 39:07sub subset of data. So, this ultimately
- 39:11improves the scalability and performance
- 39:13and especially in the larger scale
- 39:14system where single database cannot be
- 39:17handled like or cannot handle all the
- 39:19load. So, basically we we divide the
- 39:21whole load to different different
- 39:23servers. Can you tell me if you have
- 39:25given the scenario to choose SQL or
- 39:28NoSQL?
- 39:29So, when would you choose SQL and when
- 39:33would you choose NoSQL? Yeah. So, SQL is
- 39:35preferred when data is a structured and
- 39:37relationships are important such as like
- 39:40in functional or transactional uh
- 39:43systems. So, NoSQL is preferred when
- 39:46they're dealing with the large-scale
- 39:47flexible and rapidly changing data. So,
- 39:49for example, uh we have the real-time
- 39:51analytics or social media applications.
- 39:54So, in that case, no no SQL will be more
- 39:56preferred.
About this transcript
This page contains the full transcript of Deloitte Interview | Java 8 | Spring Boot | Microservices | Cloud | Docker | SQL | NoSQL | 2–7 Years by Insights Instructor, generated from the public captions YouTube serves with the video. The transcript has 6,017 words across 999 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.