Top 21 J2EE Interview Questions and Answers

Editor's note: This post was originally published around 2015. J2EE was renamed Java EE, and in 2017 Oracle transferred it to the Eclipse Foundation, where it's now called Jakarta EE. The core concepts below still apply.

Java Platform, Enterprise Edition (Java EE, originally J2EE) is the enterprise Java platform. It provides an API and runtime environment for developing and running enterprise software, including network and web services and other large-scale, multi-tiered, scalable, reliable, and secure applications.

Java EE extends the Java Platform, Standard Edition (Java SE), adding APIs for object-relational mapping, distributed and multi-tier architectures, and web services. J2EE was originally developed by Sun Microsystems.

1. What does J2EE stand for?

Java 2 Platform, Enterprise Edition.

2. What is a J2EE component?

A self-contained functional software unit, assembled into a J2EE application with its related classes and files, that communicates with other components.

3. What components does the J2EE specification define?

  • Client components: application clients and applets
  • Web components: Java Servlets and JavaServer Pages (JSP)
  • Business components: Enterprise JavaBeans (EJB)
  • Resource adapter components: provided by enterprise information system (EIS) and tool vendors

4. What are the types of J2EE modules?

  • Application client module
  • Web module
  • Enterprise JavaBeans module
  • Resource adapter module

5. What does a web module contain?

JSP files, servlet class files, static files such as images and HTML, and a web deployment descriptor. Web modules are packaged as JAR files with a .war (web archive) extension.

6. What does JSF stand for?

JavaServer Faces.

7. What is JSF?

JSF is a component-based user interface framework for building Java web applications.

8. What is Hibernate?

Hibernate is an open-source Java persistence framework. It performs object-relational mapping and lets you query databases using HQL and SQL.

9. What are the advantages of Hibernate?

  • Database independence
  • Implements the Java Persistence API (JPA)
  • Built-in connection pooling
  • Layered architecture
  • Standard ORM that maps domain objects to relational databases
  • Less boilerplate than plain JDBC

10. What are the disadvantages of Hibernate?

  • Large API to learn
  • Harder debugging
  • Can be slower than plain JDBC
  • Less suited to bulk batch processing

11. What is ORM?

Object-relational mapping (ORM) is a technique for converting data between relational databases and object-oriented programming languages. It effectively creates a "virtual object database" usable from within the language.

12. What are the benefits of ORM?

  • Productivity
  • Better application design
  • Code reuse
  • Easier maintenance

13. What does HQL stand for?

Hibernate Query Language.

14. What is HQL?

HQL is an object-oriented query language similar to SQL. Instead of tables and columns, it works with persistent objects and their properties. Hibernate translates HQL into SQL queries that run against the database.

15. What is the difference between .jar, .war, and .ear files?

  • JAR: EJB modules containing enterprise bean class files and the EJB deployment descriptor, packaged with a .jar extension.
  • WAR: Web modules containing servlets, JSP files, and static files, packaged with a .war extension.
  • EAR: An enterprise archive that packages .jar and .war modules together for deployment to an application server.

16. What does JSP stand for?

JavaServer Pages.

17. What is JSP?

JSP is a technology for creating dynamically generated web pages based on HTML, XML, or other document types. Released by Sun Microsystems in 1999, it's similar to PHP but uses Java.

18. What is Struts?

Apache Struts is an open-source framework for building Java EE web applications using the model-view-controller (MVC) architecture. Struts 1 reached end of life in 2013; Struts 2 is a separate, still-maintained framework.

19. What is Spring?

Spring is a lightweight, open-source framework for building enterprise Java applications. It reduces the complexity of enterprise development and is based on inversion of control (IoC), also called dependency injection (DI).

20. What are the benefits of the Spring Framework?

  • Lightweight container
  • No dependency on an application server (for example, no EJB or JNDI calls required)
  • Flexible object creation (for example, lazy initialization and singletons)
  • Declarative configuration of components
  • Easy property initialization
  • Declarative transactions, security, and logging through aspect-oriented programming (AOP)

21. What is a servlet?

A Java servlet is a Java program that extends the capabilities of a server. Servlets can respond to many types of requests, but most commonly power applications hosted on web servers.

Need help with a Java enterprise application? I.T. For Less can help — contact us.

I.T. Support