Showing posts sorted by date for query top-20-hibernate-interview-questions. Sort by relevance Show all posts
Showing posts sorted by date for query top-20-hibernate-interview-questions. Sort by relevance Show all posts

Saturday, November 9, 2019

Top Xl Advanced Java/J2ee Interview Questions Answers For Experienced - Iii To V Years

I have got shared many posts most Java interview query inward the past times but nothing, especially for back upwardly engineer perspective. Since at that spot are a lot of L1 as well as L2 back upwardly task exists inward BFSI (Banking, Finance, as well as Insurance Industry) as well as they are also for the longer term, I decided to write this post. When you lot move for a back upwardly engineer role, especially for Java application live on it to heart as well as person Java or Java EE application, Interviewer expects you lot know basics of Java as well as tin start/stop the application, come across log files, warning developers, as well as other aspects of the back upwardly e.g. opening conference pair to solve production issues, communicating to stakeholders, as well as involving correct peoples. In this article, I volition percentage questions to assist with technical aspects e.g. the essential skills you lot demand to clear a back upwardly engineer interview.

Even though you lot volition live on interviewed to back upwardly Java application, it's expected from you lot to know SQL, UNIX, XML as well as other key technologies which you lot volition exercise inward your day-to-day job. In this post, you lot volition notice questions which are asked to banking concern represent whether a candidate has required skills to back upwardly Java application or not.


39 Interview Questions for Java JEE Support Engineers

Here is my collection of some of the best interview questions for Java as well as JEE back upwardly professionals. If you lot are working inward production services or supporting Java application, these interview query volition assist you lot to create good on your interview. If you lot moving from evolution to back upwardly role so also these questions volition give you lot a proficient thought most what is expected from a Java JEE back upwardly engineers.

1) How create you lot banking concern represent your Java procedure is running on Linux? (example)
You tin banking concern represent past times using "ps" ascendancy as well as "grep" ascendancy e.g. ps -ef | grep "myprocess". The keyword which you lot exercise with grep for search tin live on anything unique to your process, something which appears inward its ascendancy draw e.g. get upwardly of the shape which implements the primary method. You tin also create "ps -ef | grep java" to listing all Java process.



2) How create you lot banking concern represent how much retention as well as CPU your Java procedure is consuming?
First, you lot demand to notice the PID of your process, which you lot tin notice past times using the "ps" ascendancy equally shown inward the previous question. Once you lot notice the PID you lot tin exercise the "top" ascendancy to notice the CPU as well as retention usage. Alternatively, you lot tin also exercise the prstat ascendancy equally shown here.


3) What does -Xmx as well as -Xms parameters mean?
These are parameters to specify heap size inward Java. The -Xms defines the size of the heap when JVM starts upwardly as well as -Xmx is used to specify the maximum heap size for Java application i.e. your heap cannot grow beyond that as well as JVM volition croak past times throwing OutOfMemoryError if your heap doesn't have got plenty infinite to create novel objects. See here to acquire to a greater extent than most heap retention inward Java.


4) What is the departure betwixt JVM as well as JRE?
The JRE stands for Java Runtime Environment as well as JVM stands for Java Virtual Machine. You install JRE to run Java application e.g. Applet or Core Java application or Web server similar Tomcat. The JVM is business office of JRE. See here to acquire to a greater extent than differences betwixt JVM as well as JRE.


5) What is the departure betwixt JVM as well as JIT? (answer)
The JVM stands for Java Virtual machine spell JIT stands for Just inward fourth dimension Compiler. The JIT is business office of JVM as well as used to convert the Java bytecode into native machine code which runs faster. There is some threshold gear upwardly if a code runs to a greater extent than than the threshold it becomes the candidate of only inward fourth dimension compilation past times JIT.



6) How create you lot accept the heap dump of a Java process? 
There are many ways to accept the heap dump of a Java procedure e.g. Tomcat, but most mutual is past times using tools available inward JDK e.g. jVisualVM, jCmd, as well as jmap. Here is the ascendancy you lot tin exercise to accept the heap dump of Java process:

$ jmap -dump:live, file=/location/of/heap_dump.hprof  PID

The heap dump volition comprise all alive objects as well as they are stored inward heap_dump.hprof file. Remember, you lot also demand PID of Java procedure which you lot tin notice past times using "ps" as well as "grep" ascendancy equally discussed inward the source question. You tin come across Java Performance Companion past times Charlie Hunt to acquire to a greater extent than most taking as well as analyzing heap dump inward Java to notice retention leak as well as other retention related errors. 



7) How create you lot accept a thread dump of a Java process?
Taking thread dump is easier than taking heap dump because you lot don't demand to call back tool. In Linux, you lot tin only exercise the kill ascendancy to accept the thread dump e.g.

$ kill -3 PID 

volition impress the thread dump inward the log file or where System.out is redirected. Similarly, inward Windows, you lot tin exercise Ctrl + Break from the ascendancy prompt. Alternatively, you lot tin also exercise jConsole as well as VisualVM to accept the thread dump of Java application inward both Windows as well as Linux. You tin also read Java Performance The Definitive Guide By Scott Oaks to acquire to a greater extent than most thread dump as well as heap dump.



8) What is OutOfMemoryError inward Java? How create you lot bargain with that?
The Java virtual machine throws java.lang.OutOfMemoryError when at that spot is non plenty retention to run the application e.g. no to a greater extent than retention to create novel objects, no to a greater extent than retention to create novel threads etc. The most mutual OutOfMemoryError is the java.lang.OutOfMemoryError: coffee heap space, which comes when at that spot is no to a greater extent than retention left to create a novel object.


9) What is the departure betwixt 32-bit as well as 64-bit JVM? (answer)
The primary differences betwixt 32-bit as well as 64-bit JVM are that afterward is designed for 64-bit operating arrangement e.g. Windows 8 or afterward versions of Linux. From Java developer's perspective, the primary departure betwixt them comes from heap size. Influenza A virus subtype H5N1 64-bit JVM virtually has unlimited heap memory equally compared to 4GB of the theoretical bound of 32-bit JVM. If your plan needs to a greater extent than memory, meliorate run it on 64-bit JVM with large heap space. See hither to acquire to a greater extent than most 32-bit as well as 64-bit JVM.



13) What is Garbage Collector? (answer)
The garbage collector is a element of Java virtual machine which is responsible for reclaiming retention from dead objects. It's i of the key components as well as allows an application developer to focus on application evolution rather than doing retention management. Some of the pop garbage collectors are a Concurrent Mark-Sweep garbage collector as well as G1 garbage collector inward recent times.


14) How create you lot analyze a heap dump?
There are many tools to analyze heap dump inward Java e.g. you lot tin exercise the jhat tool which comes along with JDK. You tin also exercise Eclipse Memory Analyzer to analyze heap dump to notice out whatever retention leak inward Java spell dealing with OutOfMemoryError inward Java. See Java Performance The Definitive Guide By Scott Oaks to acquire to a greater extent than about analyzing Java Heap dump.

 I have got shared many posts most Java interview query inward the past times but zero Top xl Advanced Java/J2EE Interview Questions Answers for Experienced - iii to five Years



15) What is the departure betwixt Web Server as well as Application Server? (answer)
The primary departure betwixt Web as well as Application Server comes from the fact that you lot cannot run EJB on the Web server similar Tomcat or Jetty. The application server similar WebLogic as well as WebSphere provides the runtime surroundings for EJB as well as other advanced services required past times Java EE or J2EE specification.


16) What is the departure betwixt Apache httpd as well as Tomcat?
Though both httpd as well as Tomcat are products of Apache software foundation, the httpd is to a greater extent than pop as well as used across the spider web as well as non only inward Java world. The httpd is a spider web server which tin serve static HTML files as well as dynamic content using PHP, Perl or Python, spell Tomcat is a Servlet container which provides the runtime surroundings for Servlet as well as JSP. You tin also exercise both Apache httpd as well as Tomcat together inward Java world.


17) Can you lot exercise Apache as well as Tomcat together?
Yes, you lot tin exercise Apache as well as Tomcat together. There are many Java spider web application which is fronted past times Apache spider web server to deliver static resources e.g. HTML files, images, configuration files etc. You tin so configure Apache to forwards the asking to Tomcat.


18) How create you lot start as well as halt Tomcat inward Linux?
When you lot install Tomcat inward Linux past times unzipping the downloaded package, you lot tin come across that at that spot is a startup.sh as well as shutdown.sh file inward the tomcat/bin directory. These scripts are used to start as well as halt Tomcat inward Linux. These scripts internally telephone phone Catalina.sh, the primary script to start Tomcat engine.



19) How create you lot start as well as halt Apache inward Linux?
The Apache server runs equally httpd daemon inward Linux as well as you lot tin either exercise kill command after finding the PID of httpd procedure equally shown hither or you lot tin exercise the apachectl script equally shown below to start as well as halt Apache spider web server inward Linux

Starting Apache spider web server inward Linux

$ apachectl start

Stopping Apache web server inward Linux

$ apachectl stop

Restarting Apache spider web server inward Linux

$ apachectl restart
or:
/sbin/service httpd restart

You mightiness demand root access to create if Apache spider web server is non running on your application account.


20) What is JDBC?
The JDBC stands for Java Database connectivity as well as it provides API to connect a database from Java programs. Different Java vendors e.g. MySQL, Oracle, Microsoft SQL Server, PostgreSQL they implement the API as well as provides their driver implementation to allow Java to connect to their database. Since almost every venture application has a database, JDBC is real of import for whatever existent globe projects.


21) What is the departure betwixt JDBC as well as JNDI?
As I said inward the previous answer, the JDBC stands for Java Database Connectivity as well as provides APIs as well as guidelines to connect a database from Java, spell JNDI stands for Java Naming as well as Directory Interface as well as provides a logical construction for retrieving resources e.g. database, messaging queues, venture Java beans without knowing their physical house e.g. host or port. You tin register a resources with JNDI as well as so residuum of your application element tin access them using JNDI name. The database connexion puddle is the most mutual resources accessed via JNDI inward web servers similar Tomcat or WebLogic.


22) What is database connexion pool? (answer)
As it get upwardly suggests, it only a puddle of database connections. Since creating a novel database connexion inward real-time is an expensive procedure as well as tin potentially deadening downwards the response time, many application maintains a puddle of active database connection. When a request comes inward they retrieve a connexion from the pool, acquire the information from the database as well as so render the connexion dorsum to puddle so that it tin live on reused. This way, response fourth dimension is improved inward most of the Java spider web application. See here to setup a database connexion puddle inward Tomcat using Spring framework.


23) Your Java application is connected to a Database via a connexion pool. Suddenly your database goes down? Is that an number with your Java application? Do you lot demand to restart your Java application?

hint: Since your Java application is using a connexion pool, it has active connections to database which volition acquire disconnected i time DB goes down. If you lot attempt to execute a query, you lot volition have Socket errors.



24) How create you lot shipping spider web service asking from Linux? (answer)
There are some commands available inward Linux e.g. curl as well as wget which allows you lot to shipping HTTP commands, which you lot tin exercise to telephone phone as well as essay your spider web services from Linux. Particular, Curl is used extensively to essay RESTful Web Services because it tin shipping POST request, GET request, asking with headers as well as also authenticate using both basic as well as digest authentication.

If you lot are working with REST API, I advise learning curl, it's real convenient to banking concern represent if your API is working properly using curl from the ascendancy line. You tin fifty-fifty write a script to automate those stuff.


25) What is the departure betwixt HTTP as well as HTTPS? (answer)
This is i of the mutual as well as like shooting fish in a barrel questions. Of course, you lot know the departure betwixt HTTP as well as HTTPS right? well, HTTP is insecure but HTTPS is secure, the extra "s" is for security, which agency it non exclusively encode as well as encrypt the message earlier sending but also verify the identity of the server past times using  SSL certificates provided past times global certificate government e.g. GoDaddy, Thawte, VeriSign, Digicert, GeoTrust, as well as Comodo.  See here to acquire to a greater extent than how SSL as well as Certifications run inward Java spider web application.


26) What is the departure betwixt the GET as well as POST method? (answer)
Another uncomplicated but ofttimes asked query on Java back upwardly interviews. The primary departure betwixt the GET as well as POST is that GET is both idempotent and rubber but POST is not. You tin burn GET asking multiple fourth dimension as well as it volition give the same number but multiple POST submission should ever live on avoided. GET is also used to read information from server as well as POST is used to shipping information to the server.


27) What is the departure betwixt Servlet as well as JSP? (answer)
This is some other interesting Java JEE back upwardly Interview Question. Even though both Servlet as well as JSP is used to create dynamic HTML the key departure betwixt them is their purpose. Servlet is meant for Java developers as well as you lot write to a greater extent than Java than HTML as well as that's why it serves equally Controller inward many pop MVC framework e.g. DispatcherServlet inward Spring MVC.

On the other hand, JSP is designed for HTML developers as well as it's to a greater extent than HTML than Java as well as that's why it is used equally "view" inward MVC frameworks similar Spring as well as Struts. See the link inward the reply for to a greater extent than detailed comparison.



28) What is the departure betwixt Struts as well as Spring MVC?
This is i time again a pop as well as ofttimes asked query on Java JEE Interviews. Even though both are pop spider web MVC framework for Java applications, the key departure is that Spring brings dependency injection source as well as Struts brings it afterward using Struts 2.0.

Spring is also a suite of libraries e.g. you lot acquire Spring Security to implement safety inward your application, so at that spot is Spring Boot, Spring Data, Spring Cloud as well as many to a greater extent than useful libraries nether Spring umbrella.

answer)
There are many differences betwixt JDBC as well as Hibernate but the most of import i is that JDBC provides an API to connect to the database as well as execute the query but Hibernate is an ORM (Object Relational modeling) framework, which agency it allows you lot to run with objects spell it takes aid of saving as well as retrieving object from database.

In short, inward JDBC you lot demand to write SQL queries to acquire as well as shop information from database but inward Hibernate you lot only bargain with objects, Hibernate takes aid of issuing SQL queries to the database.


30) What is the departure betwixt Stack retention as well as heap? Which i is faster? (answer)
These are only 2 dissimilar retention areas used to shop dissimilar kinds of variables. The stack is local to every thread spell heap retention is shared alongside all threads. Since Stack is closer to thread as well as unremarkably implemented using CPU registers they are faster than heap memory. The stack is used to shop local variables equally good method telephone phone frames spell heap is used to shop objects as well as shape metadata. See the detailed reply for to a greater extent than points.


31) What is the departure betwixt TCP/IP as well as UDP protocol? (answer)
There are several differences betwixt TCP as well as UDP protocol but the most of import of them is that TCP provides a guarantee of message delivery spell UDP doesn't give whatever guarantee. Because of this guarantee TCP sends to a greater extent than messages than UDP as well as thus eat to a greater extent than bandwidth as well as slower than UDP. TCP is also connexion oriented protocol spell UDP is connectionless. See the detailed reply for to a greater extent than points.

 I have got shared many posts most Java interview query inward the past times but zero Top xl Advanced Java/J2EE Interview Questions Answers for Experienced - iii to five Years



32) Your Java application is connecting to some other Java application (server) running on the remote host as well as listening on port 17865. Now, you lot don't have got access to that remote host to move as well as come across if the procedure is running. How create notice if the server is upwardly as well as running?
hint: you tin exercise the telnet command



33) You are supporting a Java spider web application which connects to many heart as well as person Java procedure as well as gets information from them to the distribution to clients? One customer complains that the asking for information is taking also long as well as it's almost similar hung? How create you lot troubleshoot this problem?

hint: banking concern represent the log, banking concern represent database, banking concern represent the file system


34) The Java application you lot back upwardly connects to a database via a DNS, which automatically switches to the secondary database server when the primary goes down. You notice that inward the trial of a failover, your Java application is non connecting to secondary DB server? How create you lot troubleshoot this problem?

hint: banking concern represent which version your Java application is running. Some JRE caches the DNS e.g. JRE 1.6

answer)
The deadlock is a status which tin occur betwixt 2 or multiple threads. In this case, each of the thread waits for each other as well as cannot progress. In Java, this unremarkably happens when thread 1 holds the lock required past times thread 2 as well as thread 2 holds the lock required past times thread 1. If your Java plan is hung so it could live on a deadlock. You tin accept a thread dump as well as notice out if whatever thread is waiting for the lock concord past times other as well as vice-versa. You tin also exercise jConsole tool to notice deadlock.


36) What is the race condition? (answer)
The race status is some other multithreading as well as concurrency põrnikas which happens due to racing betwixt 2 threads, for example, if i thread is updating a variable as well as minute thread tries to read the value earlier it finished. You tin avoid race weather condition past times properly synchronizing your code.


37) What is the departure betwixt PATH as well as CLASSPATH? (answer)
Both are key surroundings variable used past times Java platform, but the key departure betwixt them is that PATH points to the JDK binaries or native libraries e.g. java.exe, spell CLASSPATH points to Java binaries e.g. JAR files, which contains bytecode. PATH is also arrangement marker concept independent of Java but CLASSPATH is purely Java concept as well as used past times JVM to charge classes required past times Java application you lot are running.


38) How create you lot notice the Java version used past times your application? (answer)
You tin run the coffee -version ascendancy inward the ascendancy prompt to notice out the version of Java used past times your application. If you lot have got multiple JDK or JRE installed so brand certain you lot exercise the i which is used past times your application.


39) What is JAVA_HOME surroundings variable? (answer)
The JAVA_HOME is zero but a user defined surroundings variable which points to the installation directory of JDK. For example, if you lot have got installed JDK inward /opt/jdk_1.6_20 inward Linux so the JAVA_HOME variable volition betoken to this directory. Same goes for Windows or whatever other operating system.


That's all most 39 essential questions fro Java JEE Support Engineer. It's only a pocket-size gear upwardly of questions you lot tin hold off inward whatever service based companionship or investment banks but does call back to create key skills required for back upwardly engineers e.g. UNIX, SQL, Java, as well as others. In the adjacent business office of this article, I volition percentage some of the ofttimes asked questions from Java Support Engineer on SQL, UNIX, as well as other supporting technologies.


Other topic based Java Interview questions for to a greater extent than practice
  • 21 Java Inheritance Interview Questions as well as Answers (list)
  • 15 Data Structure as well as Algorithm Questions from Java Interviews (read here)
  • Top 10 Spring Framework Interview Questions with Answers (see here)
  • Top twenty Hibernate Interview Questions as well as Answers (list)
  • 10 JDBC Interview Questions for Java Programmers (questions)
  • 15 Java NIO as well as Networking Interview Questions with Answers (see here)
  • 20 Java Design Pattern Questions asked on Interviews (see here)
  • 10 Struts Interview Questions for Java developers (list)
  • 30 OOP Interview Questions with Answer (see)
  • 19 Method overloading as well as overriding interview questions (see here)
  • 10 ofttimes asked Servlet Interview Questions with Answers (see here)
  • 15 Java Enum based interview questions with answers (read)
  • 10 Oracle Interview Questions for Java developers (see here)
  • Top 10 JSP Questions  from J2EE Interviews (read here)
  • 12 Good RESTful Web Services Questions from Interviews (read here)
  • Top 10 EJB Interview Questions as well as Answers (see here)
  • Top 10 JMS as well as MQ Series Interview Questions as well as Answers (list)
  • 10 Hibernate Interview Questions for Java EE developers (see here)
  • 21 Final modifier interview questions with reply (read)
  • 10 XML Interview Questions for Java Programmers (read here)
  • Top 10 XSLT Interview Questions with Answers (read more)
  • Top 10 Trick Java Interview Questions as well as Answers (see here)
  • Top xl Core Java Phone Interview Questions with answers (list)

This list of Java interview questions for Java, JEE, as well as J2EE back upwardly engineers should live on plenty to create for whatever Java interview. You tin crevice both fresher as well as sense marker interview past times preparing these Java interview questions, at to the lowest degree source few rounds. If you lot human face upwardly whatever other interesting query which is non inward this list, so delight permit me know via comments as well as I'll add together it.

Further Learning
Java Web Fundamentals By Kevin Jones
Spring Framework 5: Beginner to Guru
JSP, Servlets as well as JDBC for Beginners: Build a Database App


Friday, November 1, 2019

Top Xx Hibernate Interview Questions For Coffee J2ee Programmers

Hibernate is i of the most pop persistent frameworks inward the Java world. Hibernate offers an object to relational (ORM) solution which frees Java developers from writing tedious, hard to read in addition to cluttered JDBC code converting SQL columns into Object properties. Apart from freeing Java developer from writing JDBC in addition to database interaction code, Hibernate likewise offers the out-of-box solution on caching, proxying in addition to lazy loading which drastically improves the surgical operation of your Java Web application. Given it's of import inward Java Web application evolution patch Hibernate has acquire of i of the most sought-after science in addition to goes manus inward manus amongst Spring framework. That's why Spring in addition to Hibernate interview questions are likewise rattling pop inward Java interviews, especially for spider web evolution positions.

Earlier I direct hold shared to a greater extent than or less Spring MVC interview questions in addition to due to pop demand, I am straight off sharing some 20 oft asked Hibernate questions from diverse Java interviews.

These questions are rattling useful for both the telephone in addition to the face-to-face circular of interviews in addition to both beginners in addition to experienced Java developers upwards to 2 to five years tin do goodness from these questions.

If you lot are actively preparing for Java interviews than you lot tin likewise banking enterprise check out Java Programming Interview Exposed, it non entirely contains interview questions from Spring in addition to Hibernate but likewise other of import Java topics e.g. heart Java, information construction in addition to algorithms, Servlet, JSP, JSF, in addition to pattern patterns.

Since no listing is consummate without user involvement, thus if you lot direct hold seen whatever practiced Hibernate questions on your interviews, which is non on this listing in addition to then experience costless to part amongst us.

You tin likewise part your ain questions for which you lot are looking answers or you lot experience it's a practiced inquiry to live asked on Java JEE programming interviews.

Btw, I await that you lot direct hold to a greater extent than or less Hibernate experience in addition to cognition before you lot cash inward one's chips through this listing of questions otherwise it would live quite dorsum in addition to forth for. If you lot are a beginner to Hibernate, I propose you lot to showtime cash inward one's chips through a course of education like Spring in addition to Hibernate for Beginners which provides all the key cognition inward quick time.

After that you lot tin meliorate sympathise the points interviewers are looking in addition to these questions volition likewise brand feel to you.




20 Hibernate Questions from Java JEE Interviews

Here is my selected listing of xx Hibernate based questions for Java developers. It contains questions from Hibernate fundamentals, one-to-one, in addition to one-to-many mappings, caching, Hibernate vs JDBC comparison, pros in addition to cons of Hibernate, known problems amongst Hibernate, in addition to Performance improvement.


1. What is Hibernate?
Hibernate is an ORM (Object-relational Mapping) framework, which allows the developer to concentrate on concern logic past times taking attention of the persistence of information past times itself. Java developer tin write code using object in addition to Hibernate tin direct hold attention of creating those object from information loaded from the database in addition to saving update dorsum to the database.


2. What are the advantages of Hibernate over JDBC? (detailed answer)
Apart from Persistence i.e. saving in addition to loading information from Database, Hibernate likewise provides the next benefits
1) Caching
2) Lazy Loading
3) Relationship management in addition to provides code for mapping an object to the data
4) The developer is costless from writing code to load/store information into the database.


3. Difference betwixt get() vs load() method inward Hibernate? (detailed answer)
This is i of the most oft asked Hibernate interview questions, I direct hold seen it several times. The key deviation betwixt the get() in addition to load() method is that load() volition throw an exception if an object amongst id passed to them is non found, but get() volition render null.

Another of import deviation is that charge tin render proxy without hitting the database unless required (when you lot access whatever attribute other than id) but get() always cash inward one's chips to the database, thus sometimes using load() tin live faster than the get() method.

Use the load() method, if you lot know the object exists, and get() method if you lot are non certain close the object's existence. See detailed answer)
The principal deviation betwixt save() in addition to persist() method is that, salve returns a Serializable object spell render type of the persist() method is void, thus it doesn't render anything.

Here is a overnice diagram which explains the land transition inward Hibernate:

 Hibernate is i of the most pop persistent frameworks inward the Java globe Top xx Hibernate Interview Questions for Java J2EE Programmers



7. What is the requirement for a Java object to acquire a Hibernate entity object? (detailed answer)
It should non live concluding in addition to must furnish a default, no-argument constructor. See the detailed respond to acquire to a greater extent than close the special requirement for a Java object to acquire a Hibernate Entity.



8. What are dissimilar types of caches available inward Hibernate? (detailed answer)
This is to a greater extent than or less other mutual Hibernate interview question. Hibernate provides the out-of-box caching solution but at that spot are many caches e.g. showtime marking cache, instant marking cache, in addition to query cache.

The showtime marking cache is maintained at Session marking in addition to cannot live disabled but the instant marking cache is required to live configured amongst external cache provider similar EhCache.


9. What is the deviation betwixt the showtime in addition to instant marking cache inward Hibernate? (detailed answer)
This is in i trial to a greater extent than follow-up of previous Hibernate interview question. The showtime marking cache is maintained at Session marking spell the instant marking cache is maintained at a SessionFactory marking in addition to shared past times all sessions. You tin read these books to acquire to a greater extent than close caching inward Hibernate.


10. Does Hibernate Session interface thread-safe inward Java? (detailed answer)
No, Session object is non thread-safe inward Hibernate in addition to intended to live used with-in unmarried thread inward the application.



11. Does SessionFactory thread-safe inward Hibernate? (detailed answer)
SessionFactory is both Immutable in addition to thread-safe in addition to it has only i unmarried event inward Hibernate application. It is used to do a Session object in addition to it likewise provides caching past times storing SQL queries stored past times multiple session.

The instant marking cache is maintained at SessionFactory level. This tin live a hard in addition to tricky inquiry for less experienced Java developers who are non familiar amongst thread-safety in addition to Immutability.


12. What is dissimilar betwixt Session in addition to SessionFactory inward Hibernate? (detailed answer)
This is to a greater extent than or less other pop Hibernate interview question, generally at a telephonic circular of interviews.

The principal deviation betwixt Session in addition to SessionFactory is that the sometime is a single-threaded, short-lived object spell afterward is Immutable in addition to shared past times all Session.

It likewise lives until the Hibernate is running. Another deviation betwixt Session in addition to SessionFactory is that sometime provides showtime marking cache spell SessionFactory provides the Second marking cache.


13. What is touchstone query inward hibernate? (detailed answer)
Criteria is a simplified API for retrieving entities past times composing Criterion objects likewise known every bit Criterion query.

This is a rattling convenient approach for functionality similar "search" screens where you lot tin filter information on multiple weather condition every bit shown inward the next example:

List books = session.createCriteria(Book.class) .add(Restrictions.like("name", "java%") ) .add(Restrictions.like("published_year", "2015")) .addOrder(Order.asc("name") ) .list();
This tin live a tough inquiry if you lot are non using Hibernate on a daily basis, I direct hold interviewed several Java developers who direct hold used Hibernate but doesn't know close Criterion query or API. You tin banking enterprise check out this listing of 5 Hibernate in addition to JPA courses for Java Programmers to acquire to a greater extent than close JPA in addition to Hibernate.


14. What are other ORM frameworks? Any option of Hibernate?
This is a full general question, sometimes asked to start the conversation in addition to other times to complete the interview. EJB in addition to TopLink from Oracle are 2 of the most pop option to Hibernate framework.


15. What is the deviation betwixt save() in addition to saveOrUpdate() method of Hibernate? (detailed answer)
Though both save() in addition to saveOrUpdate() method is used to shop an object into Database, the key deviation betwixt them is that salve tin entirely INSERT records but saveOrUpdate() tin either INSERT or UPDATE records.



16. What is deviation betwixt getCurrentSession() in addition to openSession() inward Hibernate? (detailed answer)
An interesting Hibernate interview inquiry every bit you lot mightiness direct hold used both getCurrentSession() in addition to openSession() to obtain an event of the Session object. I direct hold left this inquiry unanswered for you lot to respond or discovery an respond based on your experience.


17. What is Hibernate Query Language (HQL)? (detailed answer)
Hibernate query language, HQL is an object-oriented extension to SQL. It allows you lot to query, store, update, in addition to yell back objects from a database without using SQL.

This inquiry is likewise similar to the before inquiry close Criterion query, Java developers who direct hold non used Hibernate extensively volition non know much close features similar HQL in addition to Criterion.


18. When do you lot occupation merge() in addition to update() inward Hibernate? (detailed answer)
This is i of the tricky Hibernate interview questions. You should occupation update() if you lot are certain that the Hibernate session does non comprise an already persistent event amongst the same id in addition to occupation merge() if you lot desire to merge your modifications at whatever fourth dimension without considering the land of the session. See Java Persistence amongst Hibernate for to a greater extent than details.

 Hibernate is i of the most pop persistent frameworks inward the Java globe Top xx Hibernate Interview Questions for Java J2EE Programmers



19. The deviation betwixt sorted in addition to ordered collection inward Hibernate? (detailed answer)
The principal deviation betwixt sorted in addition to ordered collection is that sorted collection form the information inward JVM's heap retentivity using Java's collection framework sorting methods spell the ordered collection is sorted using gild past times clause inward the database itself.

Influenza A virus subtype H5N1 sorted collection is to a greater extent than suited for pocket-size dataset but for a large dataset, it's meliorate to occupation ordered collection to avoid OutOfMemoryError inward Java application.


20. How do you lot log SQL queries issued past times the Hibernate framework inward Java application?
You tin occupation the show_sql holding to log SQL queries issued past times the Hibernate framework, Just add together the next business inward your Hibernate configuration file:

<property name=”show_sql”> true </property>


21. What are the 3 states of a Hibernate Persistence object tin be? (detailed answer)
The Hibernate persistent or entity object tin alive inward the next 3 states:
1) transient
2) persistent
3) detached


22. What is the deviation betwixt the transient, persistent in addition to detached land inward Hibernate? (detailed answer)
New objects created inward Java programme but non associated amongst whatever hibernate Session are said to live inward the transient state.

On the other hand, an object which is associated amongst a Hibernate session is called Persistent object. While an object which was before associated amongst Hibernate session but currently it's non associate is known every bit a detached object.

You tin telephone band save() or persist() method to shop those object into the database in addition to convey them into the Persistent state. Similarly, you lot tin re-attach a detached object to hibernate sessions past times calling either update() or saveOrUpdate() method. See Spring in addition to Hibernate for Beginners to acquire to a greater extent than close persistence object's lifecycle inward Hibernate.


23. Which cache is used past times Session Object inward Hibernate? First marking or instant marking cache? (detailed answer)
Influenza A virus subtype H5N1 Session object uses the first-level cache. As I told before the instant marking cache is used at SessionFactory level. This is a practiced inquiry to banking enterprise check if the Candidate has been working inward hibernate or not. If he has non worked inward Hibernate from a long fourth dimension in addition to then he would acquire confused inward this question.


That's all inward this listing of Hibernate Interview inquiry for Java in addition to JEE developers. In this article, nosotros direct hold covered a lot of oft asked Hibernate inquiry for both beginners in addition to experienced Java developers from all of import topics of Hibernate framework e.g. Hibernate fundamentals, caching, collection mapping, surgical operation tuning, mutual issues in addition to Hibernate vs JDBC.

If you lot discovery that you lot lack cognition inward whatever exceptional area, I propose cash inward one's chips through next resources to fill upwards those gaps inward your knowledge.

Further Learning
Top xx Spring MVC Interview Questions 
Top xx Spring in addition to REST Interview Questions 
5 Courses to Learn Spring Boot in addition to Microservices
5 Hibernate in addition to JPA courses for Java Programmers
5 Free Courses to acquire Spring in addition to Spring Boot
Top five Spring in addition to Hibernate  Training courses
130+ Java Interview Questions from lastly five years
100+ Data Structure in addition to Algorithm Questions

Thanks for reading this article, if you lot similar this article in addition to interview inquiry in addition to then delight part amongst your friends in addition to colleagues. If you lot direct hold whatever inquiry or feedback in addition to then delight drib a comment.

Top 25 Exception Interview Questions For Coffee Programmers

1) The divergence betwixt checked as well as unchecked Exception inward Java?
For checked exceptions, the compiler ensures that they are either handled using try-catch, try-finally or try-catch-finally block or thrown away. If a method, which throws a checked exception e.g IOException as well as doesn't handgrip them or doesn't declare them inward throws degree of method, a compile-time fault volition occur. On the other hand, the compiler doesn't do similar checks for an unchecked exception, that's why it is known every bit un-checked. These are too called runtime exception because they extend java.lang.RuntimeException.

There is or thus other divergence betwixt checked as well as unchecked exception,  checked exceptions are those exception classes, which are a subclass of java.lang.Exception simply non of java.lang.RuntimeException, on the other hand, the unchecked exception e'er extends RuntimeException.

Some of the well-known examples of checked exceptions are IOException, SQLException, ParseException, etc, spell java.lang.ArrayIndexOutOfBoundsException, IllegalArgumentException and java.lang.NullPointerException has most seen examples of unchecked exception inward Java. See my post checked vs runtime exception for to a greater extent than differences.


2) What is the divergence betwixt throw as well as throws inward Java? (answer)

3) Difference betwixt finally, finalize as well as finalizer inward Java? (answer)

4) What happens when a Thread gets uncaught exception? (answer)

5) Does in conclusion runs always? On which instance in conclusion doesn't run? (answer)

6) What is try-with-resource or automatic resources management? (answer)

7) How to teach a electrical current stack draw of a Thread? (answer)

8) Difference betwixt Error as well as Exception inward Java? (answer)

9) Difference betwixt NoClassDefFoundError as well as ClassNotFoundException inward Java? (answer)

10) What is chaining of Exception? (answer)

11) How to do custom Exceptions inward Java? (answer)

12) Can nosotros accept a endeavour block without a catch? (answer)

13) What are the 5 keywords used inward Exception handling? (answer)

14) Can y'all pick out receive got of Error similar java.lang.OutOfMemoryError inward Java? (answer)


15) What is the occupation amongst the below code?

import java.io.FileNotFoundException; import java.io.IOException;  public class ExceptionInterviewQuestion_01 {      public static void main(String[] args) {         try {             multiple();         } catch (FileNotFoundException | IOException ex) {             e.printStackTrace();         }     }      public static void multiple() throws IOException, FileNotFoundException{                  System.out.println("Inside multiple");     }  }

Output: 
This plan volition non compile as well as give y'all the fault  “The exception FileNotFoundException is already caught past times the option IOException”, because FileNotFoundException is a subclass of IOException.

There are 2 ways to solve this occupation :

1) Use Simple Catch Block as well as handgrip FileNotFoundException earlier IOException

try {     multiple(); }catch(FileNotFoundException ex){     ex.printStackTrace(); }catch (IOException  e) {     ex.printStackTrace(); }

2) Only handgrip IOException instead of both FileNotFoundException as well as IOException.

try {     multiple(); }catch (IOException  e) {     ex.printStackTrace(); }
 
 
You tin farther see answer)

23) What are or thus of the best practices y'all follow spell treatment Errors as well as Exception inward Java? (answer)

24) What are the pros as well as cons of catching Throwable or Error? (answer)


That's all close or thus frequently asked Java Exception interview questions. See, how many questions y'all tin reply from this list. I'll post the reply afterward simply if y'all know the reply y'all tin e'er part on the comments section.

Further Learning
Complete Java Masterclass
see here)
  • 10 Great XML Interview Questions for Java Programmers (read here)
  • 50+ Data Structure as well as Algorithms Interview Questions (questions)
  • 20 Great Java Design Pattern Questions asked on Interviews (see here)
  • 10 pop Struts Interview Questions for Java developers (list)
  • 20+ String Coding Problems from Interviews (questions)
  • 10 oft asked Servlet Interview Questions amongst Answers (see here)
  • Top 10 JSP Questions  from J2EE Interviews (read here)
  • 12 Good RESTful Web Services Questions from Interviews (read here)
  • Top 10 EJB Interview Questions as well as Answers (see here)
  • Top 10 JMS as well as MQ Series Interview Questions as well as Answers (list)
  • 10 Great Hibernate Interview Questions for Java EE developers (see here)
  • 10 Great JDBC Interview Questions for Java Programmers (questions)
  • 15 Java NIO as well as Networking Interview Questions amongst Answers (see here)
  • 15 Data Structure as well as Algorithm Questions from Java Interviews (read here)
  • Top 10 Trick Java Interview Questions as well as Answers (see here)
  • Top forty Core Java Phone Interview Questions amongst answers (list)

  • Thanks a lot for reading this article, if y'all similar this article thus delight part amongst your friends as well as colleagues. If y'all accept whatever questions or feedback, delight drib a note.

    Top Fifty Coffee Generics In Addition To Collection Interview Questions

    Java Collection as well as Generic are a rattling of import topic for Java Interviews. They likewise nowadays around of the hardest questions to a programmer when it comes to interviews, particularly Generics. It's non slow to start sympathise what a item slice of code doing amongst those query grade as well as other signs as well as thus the pressure level of interviews likewise makes it hard to reply complex usage of Generics.  But, amongst proper training as well as paying attending to both Java Collection as well as Generic, yous tin solve that hurdle. If yous are looking for Java chore but hasn't done good inward the interviews yous convey given thus far thus yous convey come upwardly to the correct place. In this blog, I convey shared a lot of Java interview questions on diverse topics as well as difficulty levels.

    There are Java questions for beginners equally good equally practiced programmers. They are theoretical questions based upon Java programming concepts equally good equally coding as well as information construction algorithms questions for programmers, as well as this article is exclusively going to brand that collection fifty-fifty to a greater extent than valuable.

    In this article, I am going to part around of the oft asked Java Collection as well as Generic questions from Interviews. These are the questions yous convey often seen on a telephonic circular of Java interview equally good equally on face-to-face interviews. It's useful for both beginners having 2 to iii years of sense equally good equally experienced Java programmers amongst v to half-dozen years of experience.

    This listing has a collection of questions which has both slow as well as tough questions inward it but the nearly of import matter is that nearly of the questions convey already been asked on interviews. I am certain yous mightiness convey likewise seen inward your interviews. knowing the answers of these questions volition non exclusively aid yous to crevice your Java interview but likewise sympathise Java Generics as well as Collection topic in-depth, which volition eventually aid yous to write meliorate Java programmers as well as code.

    Btw, if yous are novel to Java or desire to solidify your Java cognition thus yous should cheque out a comprehensive course of written report like The Complete Java Masterclass earlier attempting to solve these questions. It volition aid yous immensely yesteryear filling gaps inward your cognition as well as going dorsum as well as forth. It's likewise the nearly up-to-date course of written report as well as covers every novel characteristic introduced betwixt Java 8 to Java 12 releases.





    50+ Java Collection as well as Generic Interview Questions

    Without wasting whatsoever to a greater extent than of your time, hither is my listing of 50+ Java interview questions on Collection as well as Generics. If yous convey done around operate inward Java thus yous should know the reply to these questions but if yous don't yous tin ever run across the answer. Instead of writing answers here, I convey linked them to relevant shipping thus that yous tin examine to solve the work yesteryear yourself hither as well as if yous demand yous tin acquire an in-depth give-and-take on private shipping to acquire the topic inward depth.


    1)  What is the Java Collection Framework as well as How do yous select dissimilar collections? (answer)
    Here is the diagram which answers this question:

     Java Collection as well as Generic are a rattling of import topic for Java Interviews Top 50 Java Generics as well as Collection Interview Questions


    2)  What is Generics inward Java? (answer)
    hint: Java characteristic to ensure type security at compile time.

    3)  Which are your favorites classes from Java Collection Framework? (answer)
    hint: Collection, List, Set, Map, ArrayList, Vector, LinkedList, HashMap etc

    4)  When do yous role Set, List, as well as Map inward Java? (answer)
    hint - role laid when yous don't demand duplicates, role List when yous demand fellowship amongst duplicates as well as role Map when yous demand to shop key-value pair.

    5)  Which Sorted Collection convey yous used? (answer)
    hint - TreeSet is 1 lawsuit of a sorted Collection

    6)  How HashSet plant inward Java? (answer)
    hint - same similar HashMap, using hashing as well as equals() as well as hashCode() method. HashSet is genuinely backed yesteryear HashMap where keys are elements yous shop inward HashSet as well as values are ever null.

    7)  Which ii methods yous should override for an Object to hold upwardly used equally a fundamental inward hash-based Collections? (answer)
    hint - equals as well as hashcode

    8)  Can yous role HashMap inward a concurrent application? (answer)
    hint - Yes, but exclusively if yous are reading from the HashMap as well as its initialized yesteryear a unmarried thread, otherwise no.

    9) What is the divergence betwixt HashMap as well as Hashtable inward Java? (answer)
    hint - HashMap is fast but non threadsafe, Hashtable is tedious but thread-safe

    10) What is the divergence betwixt synchronized as well as concurrent Collection inward Java? (answer)

    11) How ConcurrentHashMap plant inward Java? (answer)
    partitions map into segments as well as lock them individually instead of locking the whole map.

    12) What is PriorityQueue inward Java? (answer)
    Influenza A virus subtype H5N1 information construction which ever keeps the highest or lowest chemical factor at the caput thus that yous tin access or take away it inward constant time.

    13) What is type-erasure inward Generics?  (answer)
    Its a business office of Java compiler which removes all type related information later compilation from Java thus that the generated code is same similar earlier Generics.

    14) What is the divergence betwixt ArrayList as well as Vector inward Java?  (answer)

    15) What is the divergence betwixt LinkedList as well as ArrayList inward Java?  (answer)

    16) What is the divergence betwixt Hashtable as well as ConcurrentHashMap inward Java?  (answer)

    17) What is the divergence betwixt LinkedHashSet as well as TreeSet inward Java?  (answer)

    18) Difference betwixt extends as well as super inward Java Generics?  (answer)

    19) What do yous hateful yesteryear thread-safe collection? Give an lawsuit of 2 thread-safe Collection inward Java?  (answer)

    20) What is the human relationship betwixt equals as well as compareTo inward Java?  (answer)

    21) What is the default size of ArrayList as well as HashMap inward Java?  (answer)

    22) What is the charge factor, capacity, as well as Size of Collection inward Java?  (answer)

    23) What is the divergence betwixt Iterator as well as Enumeration inward Java?  (answer)

    24) When does ConcurrentModificationException occur?  (answer)

    25) What is the divergence betwixt fail-safe as well as fail-fast Iterator inward Java?  (answer)

    26) What is CopyOnWriteArrayList inward Java?  (answer)

    27) When do yous role BlockingQueue inward Java?  (answer)

    28) What is the divergence betwixt the peek() as well as poll() method of Queue interface?  (answer)

    29) How do yous detect if an ArrayList contains an Object or not?  (answer)

    30) Can nosotros shop Integer inward an ArrayList<Number> inward Java?  (answer)

    31) How acquire method of HashMap plant inward Java?  (answer)

    32) How do yous form a Collection inward Java?  (answer)

    33) What is the divergence betwixt ListIterator as well as Iterator inward Java?  (answer)

    34) What is the divergence betwixt HashSet as well as LinkedHashSet inward Java?  (answer)

    35) When do yous role EnumSet inward Java?  (answer)

    36) List downwards four ways to iterate over Map inward Java?  (answer)

    37) How to create read-only Collection inward Java?  (answer)

    38) What is IdentityHashMap inward Java?  (answer)

    39) Difference betwixt IdentityHashMap as well as WeakHashMap inward Java?  (answer)

    40) What is the divergence betwixt Comparator as well as Comparable inward Java?  (answer)

    41) What is DeQueue? When do yous role it?  (answer)

    42) How to do yous take away an Object from Collection?  (answer)

    43) What is the divergence betwixt the remove() method of Collection as well as Iterator inward Java?  (answer)

    44) What is the divergence betwixt ArrayList as well as ArrayList<?> inward Java?  (answer)

    45) What is the divergence betwixt PriorityQueue as well as TreeSet inward Java?  (answer)

    46) How tin I avoid "unchecked cast" warnings?  (answer)

    47) What is the "diamond" operator inward Java?  (answer)

    48) What is covariant method overriding inward Java?  (answer)

    50) What is the divergence betwixt bounded as well as unbounded wildcards inward Java generics?  (answer)


    That's all inward this listing of 50 Java Generics as well as Collections Interview Questions.  They are a rattling of import topic from Java Interview signal of view, particularly collections. Make certain yous fix them good earlier going for whatsoever interviews. If yous demand farther training yous tin likewise cheque out these Java Interview books as well as courses:

    Resources
    Java Interview Guide : 200+ Interview Questions as well as Answers
    Spring Framework Interview Guide - 200+ Questions & Answers
    questions)
  • Top 10 Spring Framework Interview Questions amongst Answers (see here)
  • 50+ Data Structure as well as Algorithms Problems from Interviews (questions)
  • 10 Great Hibernate Interview Questions for Java EE developers (see here)
  • 10 Great XML Interview Questions for Java Programmers (read here)
  • 20 Great Java Design Pattern Questions asked on Interviews (see here)
  • 10 pop Struts Interview Questions for Java developers (list)
  • 20 Tibco Rendezvous as well as European Monetary System Interview Questions (read more)
  • 10 oft asked Servlet Interview Questions amongst Answers (see here)
  • 20 jQuery Interview Questions for Java Web Developers (list)
  • 10 Great Oracle Interview Questions for Java developers (see here)
  • Top 10 JSP Questions  from J2EE Interviews (read here)
  • 12 Good RESTful Web Services Questions from Interviews (read here)
  • Top 10 EJB Interview Questions as well as Answers (see here)
  • Top 10 JMS as well as MQ Series Interview Questions as well as Answers (list)
  • Review these 50 Java questions earlier interviews (review)
  • 10 Great JDBC Interview Questions for Java Programmers (questions)
  • 15 Java NIO as well as Networking Interview Questions amongst Answers (see here)
  • Top 10 XSLT Interview Questions amongst Answers (read more)
  • 15 Data Structure as well as Algorithm Questions from Java Interviews (read here)
  • Top 10 Trick Java Interview Questions as well as Answers (see here)
  • Top forty Core Java Phone Interview Questions amongst Answers (list)

  • Thanks for reading this article thus far. If yous similar these Java Generics as well as Collections interview questions thus delight part amongst your friends as well as colleagues. If yous convey whatsoever questions or feedback thus delight drib a note.

    Thursday, October 31, 2019

    Top X Jump Framework Annotations For Coffee Developers

    There is no dubiousness that Spring framework is ane of the most pop Java frameworks together with it has made the life of Java developer piece of cake yesteryear providing simply about awesome features inwards the terminal xv years. Spring uses dependency injection to configure together with bind your application together but it doesn't forcefulness you lot to implement ane of its interfaces. This allows you lot to code POJO (plain onetime Java objects), a shape alongside methods together with attributes to practise most of your stuff. Then the questions come, how practise Spring provides those magical features if it doesn't inquire you lot to implement their interface, good they purpose annotations together with many of them. You volition let out simply about of the most mutual annotations inwards this article, which is must for a Java developer to run alongside Spring.

    I convey been using Spring from Spring 2.0 when everything was configured using XML, I slow moved to the annotation-driven configuration together with hence institute my agency towards Java based configuration.

    What this proves is that Spring is constantly evolving together with you lot convey to dice on upward alongside its measuring to dice on yourself up-to-date together with knowing simply about essential Spring annotations volition surely assistance inwards your journeying of Spring.

    If you lot convey been coding Java for a duad of months hence you lot may convey come upward across at to the lowest degree of the annotations. The type which starts alongside "@" like @Override, mayhap the most pop Java annotations ever. This dainty petty metadata tin practise wonders inwards damage of improving code character together with reducing the hazard of errors.

    Ever since annotations were introduced inwards JDK 1.5 they convey completely changed the Java landscape alongside to a greater extent than together with to a greater extent than framework adopting them to furnish services together with features together with Spring is no different.

    They brand heavy purpose of Annotations to furnish features you lot dear e.g. automatically detecting beans, creating their instances together with injecting them to the objects who ask them. Btw, if you lot are novel to Spring hence I propose you lot banking corporation jibe a comprehensive course of report like Spring Framework v Beginner to Guru, which volition non solely learn you lot these annotations but likewise other boundary fundamentals you lot ask to know to run effectively alongside Spring.



    Spring Core Annotations for Java developers

    Since annotations are providing the interface betwixt Java together with Spring, it's of import for a Java developer to hold upward familiar alongside the essential interface together with empathise what they practise together with how to purpose them. In this article, I'll percentage simply about of the essential Spring annotations which I intend a Java Spring developers should know.


    @Configuration
    This Spring annotation marks a shape equally a source of edible bean definitions together with it's ane of the essential annotations if you lot are using Java-based configuration.

    In before days, nosotros purpose an XML file to declare edible bean but instantly you lot don't ask to practise that, you lot tin practise classes together with convey methods which tin render Spring bean.


    @ComponentScan
    This Spring annotation instructs Spring to scan the parcel for all the @Configuration classes, which contains Spring edible bean definition inwards Java-based configuration.


    @Bean
    This Spring kernel annotation indicates that a method produces a edible bean to hold upward managed yesteryear the Spring container. This is usually used inwards the classes which are annotated alongside @Configuration annotation on the Java-based configuration inwards Spring.

    Here is an representative of @Configuration together with @Bean annotation inwards Spring inspired by Spring Framework Master Class course on Udemy:

    @Configuration public class BookStoreConfig {  @Bean public BookStoreService bookStoreService() { return new BookStoreServiceImpl(); } }

    In this example, nosotros convey annotated BookStoreConfig shape alongside @Configuration to betoken that it contains edible bean definitions. And, where are those edible bean definitions? Well, the methods which are annotated alongside @Bean annotation. In this example, the bookStoreService() method render a Spring bean.  You tin likewise check Spring Framework v Beginner to Guru for to a greater extent than examples.

     There is no dubiousness that Spring framework is ane of the most pop Java frameworks together with it Top 10 Spring Framework Annotations for Java Developers



    @Component
    This is simply about other basic Spring annotation which tin plough your shape into a Spring edible bean at the auto-scan time. In general, non all the shape you lot practise volition hold upward Spring edible bean inwards your projection but if a shape depends upon simply about other shape together with you lot desire Spring to autowire that dependency hence you lot tin annotate the shape with @Component annotation.

    One of the most pop examples of a @Component annotation is @Controller classes which human activity a Spring MVC controller together with handles HTTP requests. They are automatically detected yesteryear Spring using annotation-based configuration together with classpath scanning.

    Again, this is a shape grade annotation together with hither is an example, inspired yesteryear my favorite Spring book, Spring inwards Action yesteryear Craig Walls:

    @Component public class MangoShake implements Dessert{ .....   }

    Since this shape is annotated alongside @Component, they volition hold upward picked upward during component-scanning together with created equally a edible bean inwards the Spring application context. Then Spring tin purpose that reference to autowire whatever dependency which is looking for a Dessert object.


    @Service
    Similar to @Controller annotation used inwards Spring MVC, @Service is likewise a specialization of the @Component annotation which has no encapsulated state. You tin farther read my article, difference betwixt @Service together with @Controller annotations inwards Spring to acquire to a greater extent than nearly it.


     There is no dubiousness that Spring framework is ane of the most pop Java frameworks together with it Top 10 Spring Framework Annotations for Java Developers



    @Autowired
    This Spring annotation instructs Spring’s dependency injection to wire an appropriate edible bean into the marked shape member.

    Here is simply about other representative from classic Spring inwards Action book:

    @Autowired public void setDessert(Dessert sweet){ this.dessert = sweet; }

    When Spring volition come across this method, it volition endeavour to let out out a Spring edible bean alongside type Dessert together with tin telephone yell upward this method to inject the dependency.  See Spring inwards Action, inwards which nosotros convey a setDessert() method which uses @Autowired for auto-wiring dependency.

    Now, if nosotros convey to a greater extent than than ane Dessert edible bean inwards Spring application context hence Spring volition confuse together with non able to inject whatever dependency. Instead, it volition throw NoUniqueBeanDefinitionException.

    You tin resolve that ambiguity yesteryear using @Qualifier annotation equally shown below:

    @AutoWired @Qualifier("iceCream") public void setDessert(Dessert dessert){ this.dessert = dessert;  }

    This code volition instruct Spring to inject the edible bean alongside id "iceCream" should hold upward injected into this method.



    @Value
    This Core boundary annotation indicates a default value appear for the acre or parameter, typically something similar “#{systemProperties.myProp}”

    Here are a duad of examples of @value annotation inwards spring:

    @Value("NA") private String name

    This code injects default String value to belongings name, but instead of a simply patently string, you lot tin likewise inject values from the belongings file together with arrangement properties. See Spring Framework v Beginner to Guru for to a greater extent than examples.

     There is no dubiousness that Spring framework is ane of the most pop Java frameworks together with it Top 10 Spring Framework Annotations for Java Developers



    @Required
    This annotation tin hold upward used to specify a mandatory dependency. It tin fifty-fifty neglect the configuration if the dependency cannot hold upward injected.

    For example, you lot tin annotate a method alongside @Required to betoken it's mandatory together with required. If the setter method is non configured alongside a value, hence boundary container volition throw a BeanCreationException during the initialization stage of the bean. The required properties banking corporation jibe happens before the container starts applying the belongings values on to the bean

    Here is an representative of @Required annotation inwards Spring framework:

    public class Profile{  private String username;   @Required  public void setUsername(String username){   this.username = username;   }   }
    }

    Here username belongings is required together with if setUsername() is non called or username is non set, the edible bean creation procedure volition fail.


    That's nearly simply about of the essential Spring framework annotations. As a Java boundary developer, you lot should know nearly them together with acquire when to purpose them inwards your code. Though nosotros convey covered simply about of the basic together with most of import annotations, in that place are many to a greater extent than exists inwards Spring framework together with if you lot desire fifty-fifty to a greater extent than hence I encourage you lot to hold back at Spring Framework Master Class which covers Spring framework inwards fine details.


    Further Learning
    Master Microservices alongside Spring Boot together with Spring Cloud
    Master Hibernate together with JPA alongside Spring Boot inwards 100 Steps
    5 Free Spring Framework together with Spring Boot Courses
    15 Spring Boot Interview Questions alongside Answers
    20 Spring MVC Interview Questions for Java Programmers
    20 REST alongside Spring Interview Questions for Web developers
    3 ways to acquire Core Spring or Spring MVC better
    6 Courses to acquire Spring Framework Better


    Thanks for reading this article hence far. If you lot similar let out this listing of Spring framework annotations useful hence delight percentage alongside your friends together with colleagues. If you lot convey whatever questions or feedback hence delight drib a note.