0-Java Interview Q&A Coding Examples
0-Java Interview Q&A Coding Examples
3
What are the different scopes for spring bean ?
What is TDD?
What is REST?
...you can support multiple inheritance through interfaces (java doesn’t support more than 1 interfaces extension)
...if you put a object with a key that’s already present in the hashmap then we have to use
equal() to compare the objects content and if its different content then we can add object
...while creating immutable classes we declare all instance variables as final we cannot
change its value because final means CONSTANT not variable
If a method is throwing null pointers in super class; can we override it with a method
which throws runtime exception in child class ?
In core java, can you access non static variables declated outside of the main() in a static
context(Class.var) in the main() ?
What is singleton?
Is it better to make the whole methods sync or only critical parts sync?
if you have returns in try, catch and finally what is the order of execution ?
What is association, aggregation and composition?
What is the difference between a 1st level and a 2nd level cache in Hiberante?
What is a bean factory in Spring ?
What is Application Context ?
What percentage of code test coverage have you usually reached with your projects or work?
Have you used React or Angular before? What kind of React tests have
you written with Jest?
Step by Step: Create a REST API from scratch and display a basic
string for a GET request using Spring Boot
Change folder structure: group.artifact.controllerFolder
Change folder structure: group.artiface.modelFolder
Inversion Of Control (IOC) - delegate responsibility to another class
Threads acquire class level locks via [static sync function OR sync block]
Threads acquire object level locks via [sync function ]
Functional Interface contains 1 abstract function
string is Immutable in Java because String objects are cached in the String pool
Comparable is a interface to compare a object on 1 instance variables to sort the list of objects
Comparator is a interface to compare a object on 1+ instance variables to sort the list of objects
triggers are functions that track db table updates
primary keys are unique and define the row (we cannot have null primary keys)
we can have null unique keys and a combination of columns make up the unique keys
Concurrent hashmap; reading or updating locks on the row and not the entire datastructure object
Hashtable ; reading or updating locks the entire datastructure object
put() calculates hashcode and find a bucket and see if the hashcode matches or not
if hashcode is matching but value is different then another node will be inserted
microservices modularize controller functions that handle api web service calls
unit test is testing objA.fA()
integration test is testing objB.objA.fA()
thinking of all test cases means we are writing down the requirements first and using it to code so
developing in that manner means accurately developing the code to fullfill the requirements
REST is a an API that communicates between a web browser and a web server executing MVC Code
yes; We can have two or more static methods with the same name, but different input param
First level cache is a session level cache and it is always associated with session level object. This type
of cache is used for minimizing Db interaction by caching the state of the object. That is instead of
updating after every modification done in the transaction, it updates the transaction only at the end of
the transaction.
Second level cache is session factory level cache and it is available across all sessions.While running the
transactions, in between it loads the objects at the Session Factory level, so that those objects will be
available to the entire application, not bound to a single user. By default, it is disabled in hibernate.
Git Server -> Global Config Server -> Microservice gets global configs
1st, we add a parameter in application.properties file to tell Spring to use a different env specific
property file corresponsing to the active profiles
spring.profiles.active=@activatedProperties@
2nd, we
have to create 2 new env specific property files in the same path as application.properties file (one to be
used by the DEV profile and one to be used by the PROD profile) application-
dev.properties
application-prod.properties
Within each
of these files, properties can be defined that will only be applied when the corresponding profile is
active.
Configuration of dependencies are read from XML, annotations or Java DSL (JavaConfig). Then Spring DI
engine wires the dependencies based on the metadata from the configuration using the Java reflection
API.
Singleton scope in the spring framework is the default bean scope in the IOC container. It tells the
container toisexactly
If the scope create
declared a singlethen
prototype, instance of IOC
spring the container
object. This single
will instance
create a new is stored in
instance of the
thatcache
bean and
all the
every subsequent
time a requestrequests for that named bean return the cached instance.
Singleton is the isdefault
made for that specific
scope bean. A the
for a Bean, request
onecan be made
that to used
will be the bean instance either
if nothing else
programmatically using getBean() method or by XML for Dependency Injection of secondary type.
is indicated. This scope implies that Spring container will create an only shared
Singleton
instanceScope
of the class designated by this bean, so each time the Bean is required the
same object will be injected.
SonarCloud is a cloud-based code quality and security service for catching Bugs and Security
Vulnerabilities in your Pull Requests and throughout your code repositories.
pipelines are a series of automated steps that must be performed in order to deliver a new version of software
80% to deliver
Reactive Programming is a programming paradigm that focuses on making async and non blocking
component Spring
Webflux is a reactive-stack web framework that is fully non-blocking, supports Reactive Streams
yes. No i have not written any react tests using JEST
@ Controller Advice is a specialization of @Component which allows to handle exceptions across the
whole application in one global handling component
The current stable version, as of July 2022, is Spring Boot 2.7
UPDATE User SET loan = 100 WHERE loanName IN ('loanA', 'loanB', 'loanC');
DispatcherServelet acts as a front controller for Spring Web Apps by handling incoming http requests,
delegates the http requests and processess the http requests per controller functions ,end points and
response objects
Spark is a big data processing framework; Spring boot is a back end framework for making web apps
n Spring
interface which has functional interface.
he String pool
but different input parameters
rsion of software
Java Concept Clarity https://www.youtube.com/watch?v=hainZwgvGYY&list=PLk58B65P9YaZIUuZICiQOt9W
Spring Boot Concept Clarity https://www.youtube.com/watch?v=-_tPeb3VE6w&list=PLk58B65P9YaZfKMxVue4LA2
=PLk58B65P9YaZIUuZICiQOt9WXBAO_r_oR
=PLk58B65P9YaZfKMxVue4LA2M0iFg7KR1U