Java EE interview questions

Source: Internet
Author: User

1. What is Java ee?
A: Java EE is a multi-layer (Multi-diered), distributed (distributed), and component-based enterprise-level application model (enterpriese application model) proposed by Sun ). In such an application system, different components can be divided by function. These components can be located on different computers and at the corresponding level (Tier. The hierarchy includes the Client layer (clietn tier) components, web layer and components, business layer and components, and enterprise information system layer.

2. Please explain the terms commonly used in Java EE below. 
Answer: (1) EJB container: Enterprise Java Bean container, which is more industry-specific. It provides various management functions for the component EJB running in it. As long as the EJB meeting the J2EE specification is put into the container, it will be managed efficiently by the container immediately, and the system-level services can be obtained through the ready-made interface. For example, mail service.
(2) JNDI: it is all called Java Naming Directory Interface. The main function is to provide a directory system that allows applications from other places to leave their own indexes on it to quickly find and locate distributed applications.
(3) JMS: it is called Java Message Service and translated into Java Message Service. It mainly implements communication between various applications, including point-to-point and broadcast.
(4) JTA: a Java transaction API. Various distributed transaction services are provided, and applications only need to call the interfaces provided by them.

(5) JAF: Java action framework. Provides some security control frameworks for developers to implement their own personalized security control policies through various deployment and customization.

3. What types of EJB are available?
A: EJB includes three types: Session Bean, Entity Bean, and message-driven bean.
Session beans can be divided into two types: stateful and stateless.
Entity beans can be divided into two types: bean management continuity and container management continuity.

4. Explain the role of EJB and the three objects.
A: A complete EJB-based Distributed Computing structure consists of six roles, which can be provided by different developers, each role must follow the EJB specifications provided by Sun to ensure compatibility between them. These six roles are the EJB component developer, application composite, deployer, EJB server provider, EJB container provider, and system administrator. The three objects are the remote interface, home interface, and Bean class.

5. What is the difference between EJB and Java Bean?
A: Java Beans are reusable components and there is no strict specification for Java Beans. Theoretically, any Java class can be a bean. However, since Java Beans are created by containers (such as Tomcat), Java Beans should have a constructor without parameters. In addition, generally, Java Bean must implement the serializable interface to realize bean persistence. Java Bean is actually equivalent to the COM component in the local process in the Microsoft COM model. It cannot be accessed across processes. Enterprise Java Bean is equivalent to DCOM, which is a distributed component. It is based on Java remote method calling RMI technology, so EJB can be remotely accessed, but EJB must be deployed in containers such as webspere and weblogic, the EJB client never directly accesses the real EJB component but accesses it through its container. The EJB container is the proxy of the EJB component,
EJB components are created and managed by containers. The customer accesses the real EJB component through the container.

6. What are the main services provided by the EJB container?
A: It mainly provides services such as declarative cycle management, code generation, continuity management, security, transaction management, lock and release management.

7. What are the basic steps for a client to call an EJB object?
A: set the properties of the jndi service factory and the JNDI service address system, find the home interface, call the create method from the home interface to create a remote interface, and call its business method through the remote interface.

8. What are the main functions of the remote interface and home interface?
A: The remote interface defines the business method used by the EJB client to call the business method.
The home interface is used by the EJB factory to create and remove EJB instances.

9. Describe the EJB activation mechanism in detail.
A: Taking stateful Session Bean as an example, the cache size determines the number of bean instances that can coexist in the memory. According to the MRU or NRU algorithm, instances are migrated between the activation and deactivation statuses, the activation mechanism is that when the client calls a business method of an EJB instance, if the corresponding EJB object finds that it is not bound to the corresponding bean instance, it will activate bean storage from it (storage instance through serialization mechanism) reply to this instance. The corresponding EJB active and EJB passivate methods are called before the status changes.

10. Is Java ee a technology, a platform, or a framework?
A: J2EE is a standard platform for enterprise distributed application development. J2EE is also a framework, including JDBC, JNDI, RMI, JMS, EJB, JTA and other technologies.


11. What operations are prohibited in ejbs In the EJB specification? 
A: The EJB specification stipulates that operations prohibited by ejbs include:
(1) threads and thread APIs cannot be operated (thread APIs refer to methods of non-thread objects, such as notify and wait ).
(2) AWT cannot be operated.
(3) server functions cannot be implemented.
(4) The static owner cannot survive.
(5) the file system cannot be directly accessed using Io operations.
(6) The local database cannot be loaded.
(7) You cannot use this as a variable or return.
(8) It cannot be called cyclically.

12. Does EJB need to directly implement its business interface or home interface? Briefly describe the reason.
A: The remote interface and home interface do not need to be implemented directly. Their implementation code is generated by the server. The corresponding implementation class in the program running will be used as an instance of the corresponding interface type.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.