Top 40 Popular J2EE Interview Questions and Answers You Should Read

By Vijay

By Vijay

I'm Vijay, and I've been working on this blog for the past 20+ years! I’ve been in the IT industry for more than 20 years now. I completed my graduation in B.E. Computer Science from a reputed Pune university and then started my career in…

Learn about our editorial policies.
Updated March 9, 2024

Most Frequently asked J2EE Interview Questions and answers:

J2EE stands for Java 2 Platform Enterprise Edition. It is an open and standards-based platform for development, deployment, and management of multi-tier, web-enabled, component-based and server-centric enterprise applications.

There are several Application programming interfaces comprised of J2EE for building such systems.

This document focuses on the understanding of J2EE concepts, theories, and some common coding techniques.

J2EE Interview Questions And Answers

Most Popular J2EE Interview Questions And Answers

These J2EE questions are useful for experienced professionals as well.

Here we go.

Q #1) What are the components of J2EE applications?

Answer: The components of J2EE applications include:

  • Client-tier components: Run-on the client machine.
  • Web tier components: Run-on the J2EE server.
  • Business tier components: Run-on the J2EE server.
  • Enterprise Information System software (EIS software): Runs on the EIS server.

Q #2) What are the J2EE client types?

Answer: J2EE client types are

  • Applets
  • Application clients
  • Java Web Start enabled clients, by Java Web Start technology.
  • Wireless clients, based on the Mobile Information Device Profile (MIDP) technology.

Q #3) What is a J2EE container?

Answer: The interface between a component and the low-level platform with specific functionality that supports the component is called a container. The application server maintains control and provides relevant services through an interface or framework calls as a container.

Q #4) What are defined as web components?

Answer: Java Servlets and Java server pages technology components are identified as web components. Servlets dynamically receive requests and make responses. JSP server pages also behave as Java Servlets but facilitate to create more static content.

Q #5) Describe the MVC on struts?

Answer: MVC stands for Model View Controller. Each section in the Model View Controller can be described as follows:

  • Model: Model represents the internal state of the system as a set of single or many Java Beans.
  • View: Most often the view is constructed using Java Server Pages (JSP) technology.
  • Controller: The controller is the process that focuses on receiving client requests and produce the next level of a user interface according to the request. The primary component of the controller in the framework is the “ActionServlet” servlet class.

Q #6) Define JSF?

Answer: JSF stands for Java Server Faces. It is the user interface (UI) designing framework for Java Web application developments. There is a set of reusable UI components associated with JSF. Also, JSF has based on Model-View-Controller (MVC) design concepts and patterns. The automated data saving process from form to server and display at the client side is also handled by JSF.

Further reading =>> JSF Interview Questions

Q #7) What is Hashtable?

Answer: Hashtable is a collection synchronized object. It allows null value but not the duplicate values. Hashtable is like a HashMap.

Q #8) Define Hibernate?

Answer: Hibernate is an open-source object-relational mapping and query service which facilitates writing Hibernate Query Language (HQL) scripts instead of Structured Query Language (SQL) scripts.

It is a fast and easy process than writing native SQL. Hibernate has more powerful object-oriented contents like associations, inheritance, and polymorphism. Also, it has powerful compositions and collections. Hibernate allows making queries using a Java-based approach.

Q #9) What are the identified limitation of hibernate?

Answer:

  • Slower in action: In execution of HQL queries take more time than it executes directly.
  • Only composite key support is available and it prevents advanced query options.
  • No shared value type references are available.

Q #10) What are the identified advantages of hibernate?

Answer: Advantages are:

  • Database and vendor independence application.
  • Standard Object-relational mapping support.
  • Domain object mapping for a relational database.
  • Better performance than Java Database Connectivity.
  • Java Persistence API based applications.

Q #11) Describe ORM?

Answer: Object-Relational mapping (ORM) can be described as follows:

The mapped objects in a Java class to the tables of the relational database using metadata describes the database and object mapping. The working method is to transform data from one representation to another.

Q #12) What are the advantages of Object-Relational Mapping (ORM)?

Answer: Advantages are:

  • Productivity: Reduced time for data access coding with the help of automatic code creation base on the defined data model.
  • Maintainability: All code generated from ORM are well tested. Only the developer is required to create the correct functionality
  • Performance: The code generated from ORM completely manages the data access needs of the application. No need to create any data access code. Also, the code is optimized to speed up the data access process.
  • Vendor independence: The code generated from ORM does not depend on the vendor. This is to increase the portability of the application.

Q #13) What is the use of method save()?

Answer: In hibernate, this method is used to stores an object into the database. There is a check for duplicate records before inserting it.

Q #14) What is the use of method saveorupdate()?

Answer: In hibernate, method saveorupdate() is used to update an object using the identifier. When the value for the identifier is NULL then the method is directed to call save().

Q #15) What is the difference between load() and get()?

Answer: When the object is not available in either cache or database, the load() method throws an exception. No null values are returned from the load() method.

When the object is not available in either cache or database, get() returns null.

Q #16) What is meant by connection pooling?

Answer: Connection pooling is a mechanism to re-use the existing connections. The pooling mechanism maintains a number of already created object connections and when there is a demand, the mechanism directly uses the existing connection without creating a new one.

Q #17) Define the Collection types in Hibernate?

Answer: One-to-many reference is defined as a collection. There are five main collection types associated with J2EE. They are: Set type, List type, Array type, Map type, Bag type

Q #18) Define a thin client?

Answer: A program interface that does not have any operations like database queries, complex business rules or any connection to the third-party application is called a thin client.

Q #19) Describe the file types *.ear, * .jar and *.war?

Answer:

  • *.jar files – Property file containing libraries, resources, and accessories are included with the *.jar file extension.
  • *.war files – The files that are required for the development of web application (HTML, java scripts, JSP) are included with a *.war file extension.
  • *.ear files – The files for Enterprise Java Beans modules for the application are saved as *.ear files.

Q #20) How spring is related to J2EE?

Answer: Spring is an open-source application that reduces the complexity of enterprise application development. Spring is based on an inversion of control or dependency injection design patterns.

Q #21) What are the advantages of using spring for application development?

Answer:

  • Plain Old Java Object (POJO) based development facilitates to re-use existing components.
  • Possible to reduce development cost by improving the productivity of the application development.
  • Improve the testability of application with dependency injection.
  • Improve maintainability with reduced code coupling.
  • No need to have an application server and works on enterprise service.

Q #22) Discuss the benefit of the Spring Framework?

Answer: Benefits are as follows:

  • Possibility to organize middle-tier objects in an efficient way.
  • Easy initialization for properties.
  • Easily testable components.
  • Lightweight container.
  • Possibilities to use configuration management service of spring in any runtime environment with whatever architectural layer.

Q #23) Describe servlet?

Answer: The Server-side component that provides a powerful mechanism to create server-side programs is called a servlet. There are servlets available with a design for various protocols. Servlet is also server and platform-independent. The most commonly used protocol for the servlet is Hypertext Transfer Protocol (HTTP). Also, a servlet is a pure java object.

Q #24) Describe the phases of the servlet lifecycle?

Answer: The phases of servlet lifecycle are:

  • Classloading phase – Web container loads the servlet class file (*.class).
  • Instantiation phase – By calling default no-arg constructor, the servlet class gets Instantiated.
  • Initialize phase – The method Init () called in this phase in only one time of the lifetime of a servlet. Servlet configuration is assigned to the servlet.
  • Request Handling phase – In this phase, only servlets spends most of the time. Servlet provides the services to various requests by calling Service ().
  • Removal phase – The destroy () function is called before servlet destruction. Garbage collection occurs later.

Q  #25) What are the different types of JSP tags?

Answer: There are 4 different types of tags associated with JSP. They are mentioned below:

  • Directives
  • Declarations
  • Scriptlets
  • Expressions

Q #26) Describe the action form?

Answer: A Java bean that is associated with single or multiple action mapping is called an action form. Action form objects are automatically populated at the server end when data has been entered from the client side through a user interface (UI).

Session states of a web application are maintained by action forms.

Q #27) Describe the Secure Socket Layer (SSL)?

Answer: The technology that is used to communicate between the web server and the web browser is called Secure Socket Layer (SSL). More specifically, SSL is a protocol that describes how algorithms are to be used in encryption.

The technology establishes an encrypted link between two parties and this link is allowed to secure transmission of sensitive information such as login credentials, credit/debit card information and social security numbers.

Q #28) What is id URL?

Answer: URL stands for Uniform Resource Locator and it is the textual reference writing standard to an arbitrary piece of data in the World Wide Web (www). The general structure of the URL is as follows:

protocol://host/local info

  • protocol – Protocol is for fetching the object (example: HTTP, FTP)
  • host – Internet name of the targeted host.
  • local info – String is passed to the protocol handler on the remote host. In many cases, it is a file name with an extension.

Q #29) What is URN?

Answer: URN stands for the Uniform Resource Name. It is a unique identifier that identifies an entity. But the information on where the entity is located is not available.

Q #30) What are the steps associated with the servlet life cycle?

Answer: The following steps are associated with the servlet life cycle:

  • Loading of the servlet class.
  • Instantiation of Servlet.
  • Execution of the init method.
  • Request handling phase. In this phase, service methods are called.
  • Removal from the service phase. In this phase, the destroy method is called.

Q #31) Is Servlet is pure java object or not?

Answer: Yes, Servlet is a pure java object.

Q #32) What is EJB?

Answer: EJB stands for Enterprise Java Beans. It is the server-side component that executes in EJB container and encapsulates the business logic for the enterprise application.

Q #33) What are the system services of the EJB container?

Answer: EJB Container provides the following system services:

  • Persistence
  • Security
  • Transaction
  • Connection pooling
  • Component lifecycle management
  • Threading

Q #34) What are the design principles for EJB?

Answer: Design principle includes:

  • The behavior of the EJB application is specified by interfaces.
  • EJB applications are loosely coupled and tired.
  • Implementation is hidden from the client-side.
  • The EJB container supports the application developer.
  • The API to the application is in session tier.
  • The API to the data sources is in the entity tier.

Q #35) What are the advantages of EJB components?

Answer: Advantages are:

  • There is support for the integration of components from different vendors.
  • Possibility to authorize the EJB component’s detailed knowledge of the environment.
  • Possibility to assemble applications from separate component sources.
  • Interaction with its clients is entirely specified in terms of Java interfaces.
  • Portability support.
  • It does not maintain resources.

Q #36) What are the Basic and subtypes of Enterprise Java Beans (EJB)?

Answer: Two main types and subtypes of EJB are as follows:

  • Session Beans
    • Stateful session beans
    • Stateless session beans
  • Entity Beans
    • Bean Managed Persistence (BMP)
    • Container-Managed Persistence (CMP)
    • Message Driven Beans

Q #37) What is the description of the expression element?

Answer: The expressions used for writing dynamic content back to the client browser are called expression elements.

Q #38) What are the two types of comments supported by JSP?

Answer: Two types of comments supported by JSP are:

  • HTML comment:

HTML comment

  • JSP comment.:

JSP comment

Q #39) What is called the JSP directive?

Answer: JSP directive is the mechanism to provide metadata information to web containers about the JSP file. In the translation and compilation phases of the JSP life cycle, this Metadata is used by the web container.

Q #40) What are the different types of JSP directive?

Answer: There are 3 different types of JSP directives available. These are:

  • Page directive
  • Include directive
  • Taglib directive

Conclusion

The above list contains frequently asked J2EE interview questions with the best descriptive answers on different J2EE concepts like JSP, Servlet, EJB, and spring. The question set is useful for both fresher as well as 2-6 years experience programmers to have a quick guide in specific questions.

Was this helpful?

Thanks for your feedback!

Leave a Comment