Java Interview Questions and answer for experience
Spring Boot Questions :-
Disable
Tomcat server
FromSpringStarter we can add @SpringBootApplication(exclude =
{EmbeddedServletContainerAutoConfiguration.class,
WebMvcAutoConfiguration.class}) annotation to remove embedded tomcat server
Or
execlude tomcat starter web from pom.xml
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
How to Change
Tomcat port:-
server.port=8081
How to Disable
web server dependencies
spring.main.web-application-type=none
How to disable AutoConfigure class :-
@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class})
What
does @SpringBootApplication do :-
@SpringBootApplication
annotation can be used to enable those three features, that is:
@EnableAutoConfiguration:
enable Spring Boot’s auto-configuration mechanism
@ComponentScan:
enable @Component scan on the package where the application is located
@Configuration:
allow to register extra beans in the context or import additional configuration
classes
How
to get Application. Properties value in java
@Value("${my.name}")
String value;
@RestController is ?
@RestController annotation in order to simplify the creation of RESTful web
services. It's a convenient annotation that combines @Controller and
@ResponseBody, which eliminates the need to annotate every request handling
method of the controller class with the @ResponseBody annotation.
Diff
@Controller and @RestController :-
@Controller returns View. @RestController returns ResponseBody.
@Controller
is used to mark classes as Spring MVC Controller.
@RestController is a
convenience annotation that does nothing more than adding the @Controller and
@ResponseBody annotations
@GetMapping
and @RestMapping
@RequestMapping
is a method level
@GetMapping
is a method-level
@GetMapping is a composed annotation that acts as a shortcut for
@RequestMapping(method = RequestMethod.GET)
Spring Profile
works :-
spring.profile.active=prod it will load application-prod.properties details
java -jar springboot-0.0.1-SNAPSHOT.jar --spring.profiles.active=prod
Actuator:-
It adds several production grade services to your application with little
effort
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
To
expose Other webdetails :- management.endpoints.web.exposure.include=*
How to handle Exception in Rest API or SpringBoot :-
Handling
exceptions and errors in APIs and sending the proper response to the client is
good for enterprise applications.
- what are OOPS concepts? explain in detail?
- explain abstraction and interface?
- what is serialization?
- write code for Singleton class?
- method overloading and overriding and limitations on it?
- Explain steps in Hibernate to update DB and Write Hibernate code for same?
- Explain caching and cache levels in Hibernate?
- Different annotations in Spring?
- Soap vs REST? which is better in terms of security?
- Write a immutable class?
- String vs String Buffer vs String Builder?
- Explain exception hierarchy?
- Have you worked in Multi Threading environment? explain
- if Array input is 12345 then change its order to 45123? write code?
- Write java code to find minimum diff from array in java .
- Second largest from element.
- write query to remove all duplicates and keep one record for each row
- delete from
- (select name,count(name),rownumber()
- from table1
- group by name )
- where row_number >1
- Write a deadlock program
- restcontroller vs requestmapping
- design patterns
- deadlock condition -how to identify ?? visaulvm?
- completable future
- immutable class
- LRUCache - how to create
- threadpools - benefit, how it works
- get all max hundred from list of million numbers
- java memory model - what does java gurantees interms of visibitliy
- make a private method to public
- generics-super,T, ? usage
- thread pool types - how it works
- Order of get put in linked list
- how to synchronization in a wrapper class for hashmap -put and get operations without using exising ways(collections/concurrency apis)
- Different ways to synchronize opeartions
- Priority queue - data structure used
- callable vs runnable tasks
- Future,CompletableFuture
- countdownlatch vs cyclicbarrier
- CAP theorem
- truncate vs delete vs drop
- ACID property
- types of indexing
- types of joins
- garbage collections algorithms
- Normalisation in dbms - details
- candidate key , super key
- evict method in hi
- bernate
- jpa vs hibernate
- jpa specification for custom query
- executor framework
- execute vs submit
- callable vs runnable
- spring bean lifecycle
- spring annotations
- @qualifier
- @requestparam vs @pathvariable
- security in services
- concurrentmodification exception usecase
- exception handling in spring boot
- spring batch transaction rollback
- classnotfoundexception vs noclassdeffounderr
- shadow vs deep cloning
- types of design patterns worked
- countdownlatch
- arraylist vs linkedlist
- hashset internal
- Not many programmer know that HashSet is internally implemented using HashMap in Java,
- Remember to override equals() and hashCode() for any object you are going to store in HashSet,
- Read more: https://www.java67.com/2014/01/how-hashset-is-implemented-or-works-internally-java.html#ixzz6rT8UI026
- hashtable vs hashmap
- auto configuration in spring boot - how it works
- restcontroller vs controller
- minimum number operations to convert str1 to str2
- https://www.geeksforgeeks.org/edit-distance-dp-5/
- Reverse a linkedlist
- LinkedList list = new LinkedList();
- list.add(10);
- list.add(20);
- list.add(30);
- list.add(40);
- System.out.println(list);
- for (int i = list.size() - 1; i >= 0; i--) {
- System.out.println(list.get(i));
- }
- }
- singleton class with thread safety
- hashmap internal
- completable future
- design chess
- design report generation tool with scheduling capabilties for ecommerce
- singleton class
- types of design patterns
- scaling
- performance improvement
- system design of current project
- why spring boot
- when to use interface and when to use abstract class
- strategy design pattern
- streams
- thread life cycle
- concurrent hashmap disdvantages
- why singleton instance is static
- soap vs rest
- command design pattern
- executors vs threads
- thread
- concurrenthashmap vs hasmap
- executors fairness policy
- pattern matching algorithms(KMP,Rabin Karp,etc)
- kafka offset
- oops principles
- sql - 2nd highest salary
- cached vs fixed thread pool - behaviour difference
- singleton class eager vs lazy
- hibernate eager vs lazy
- hibernate types of caching
- 1st level - session
- 2nd level - session factory
- DCL commands
- DDL commands
- primary vs unique key
- idempotent methods
- types bean wiring in spring
- types of injection in spring
- default bean scope
- reverse a string
- how to write in lambda function
- program to read a file
- stop singleton from breaking in reflection
- @Qualifier
- marker interface
- throw vs throws
- linkedhashmap vs treemap
- spring autowiring types
- SQL - 3rd highest age from table emp (name, age)
- strict keyword in javascript?
- @superclass mapper annotation in hibernate?
- adaptor design pattern?
- what does sonarqube do?
- how do you make sure standards are followed ?
- How SSO works technically?
- how session is maintained during loadbalancing when req sent to different instance?
- what is Abstraction and Encapsulation?
- What for we use Executor Service?
- How can you disable Tomcat from Springboot?
- Use of Countdownlatch and CyclicBarrier?
- Use of Stream API?
- what is Functional Interface in java?
- Optional Class is java?
- Write Singleton class ?
- what is semaphores?
- Global exception in MVC?
- ArrayList and LinkedList what data structure they use internally?
- what is role of ActionServlet?
- what info present in Struts-config.xml?
- How to invalidate session?
- implicit objects in JSP?
- Difference between Bean and Component?
- When do we use 2nd Level caching in hibernate and How enable it?
- How do you integrate Spring with Hibernate?
- Return Type of Action Class execute() in Struts?
- How session info is stored in browser ?
- Metods of Servlet?
- what are tags used by you in JSP?
Latest Interview question :- MAY-JUN 2021
What is qualifier.
Define binary tree with one example
How hashmap use o(1) and list uses o(n)
How spring profile works
Spring AOP
HashMap internal works
Concurrent hashmap with internal implementation
Fail fast and fail safe define way to handle fail fast .
Daemon thread.
Thread executor and how to check how many threads completed and how many are still running
Time complexity
How to make services scalable
How to handle content navigation in rest .
Handle custom exception in rest api or spring boot api .
What is load balancer .
Difference between hashtable and hashmap
What is functional interface why we need
What is the advance having default method in functional interface
Logback in spring boot
How to handle retry scenario in spring boot
How to exclude few beans from configuration
How to deploy changes via putty .
What is difference between scp and cp
Countdown latch .
What is data watch .
Spring internal IOS container works
Collections classes and their subclasses .
How to stop saving other object in one to many mapping
Write thread scheduler .
Can we override static method and if not why what is that concept called.
What is fat jar or uber jar .
Cache works in hibernate.
How to stop saving one field from hibernate entity classes
How to handle multiple language in code.
Lazy loading in hibernate what is real use.
Define stream api in details with some custom check;s
JodaTime api java
How to convert string into date .
How to consume rest api from RestTemplate .
How to return HTTPstatus code along with Object.
How to get Param from controller.
Instead of JPArepository what else we can use.
How to check if database contain duplicate value .
How indexing works in mongodb.
Mongodb dump generation .
Mongodb dump type.
Design database or code level details for facebook app.
Cluster
How to enable listener in IBM.
Ant build file
Custom exception
How to create singleton thread class with double checked in .
How string constant pool works and diff b/w string str=”A” and String str= new String (“A”)
How Kafka works
What are the component in kafka
Partition in kafka
API gateway in microservices.
How JWT token split and what does it contain .
What is spring security .
How to deal with barrier token .
How to check performance of rest API
setTime out in client side with jquery.
Ajax call with loading feature .
Parse JSON on Jquery.
Kendo UI feature
Kendo UI chart display feature .
What is JSON parser how many ways we can consume
============================
Difference between Primary key and Unique key
between between entity class and pojo class
microservices communicate with each other
two Microservices Communicate--Annotation we are using
How to handle log file
What is spring boot acurator
Feature or banifit for Spring boot vs Spring
Why Spring boot introduce
whats its benefits
list of the 9 implicit objects in Jsp
JSP types of directives:
Command Design Pattern
Strategy Pattern:
Filter Pattern
Singleton Pattern:
serialization Question
Whatn is InvalidClassException
What is yield()
diff between finally and final
can we define finally block without catchblock
In coding
Sort an array which contain Integer,String
using java 8
Count total no of character in string using java 8
add two number without + operator
Diff between Stream.filter or Stream.map
and Stream.forEach or Stream.reduce
what is circuit breaker
Coding in Armstrong By Java8
2nd largest no in array
java 8
Java 8 Question :
What is Funct Interface
What is Stream API
Whay they have introduce it
How to overcome multiple inheritance in java 8
Create singalton coding
Comments
Post a Comment