1. What is the difference between arraylist and vector? What is the difference between hashmap and hashtable?
A:Arraylist and vector are mainly used in two aspects.
A. Synchronization: the vector is thread-safe, that is, synchronous, And the arraylist is not secure or synchronous.
B. Data growth: When we need to increase, the vector will double the original growth by default, while the arraylist will be half of the original growth.
Hashmap and hashtable are mainly used in three aspects.
A. Historical Reasons: hashtable is based on the obsolete dictionary class, And hashmap is an implementation of the map interface introduced by Java 1.2.
B. Synchronization: hashtable is thread-safe, that is, synchronous, while hashmap is non-secure or not synchronous.
C. Value: Only hashmap allows you to use a null value as the key or value of a table entry.
2. What are several implementation methods for multithreading? What are the implementation methods of synchronization?
A: multithreading can be implemented in two ways: Inheriting the Thread class and implementing the runnable interface.
There are two types of synchronization implementation: synchronized, wait, and Y.
3. What built-in objects does JSP have? What are their roles?
A: JSP has the following nine basic built-in components (which can correspond to the six internal components of ASP ):
RequestClient request, which contains parameters from the get/POST request
ResponseResponse from the webpage to the client
PagecontextThe webpage attribute is managed here
SessionRequest-related Session Period
Content being executed by application Servlet
OutUsed to send response output
ConfigServlet architecture Components
Page JSP page itself
ExceptionExceptions not captured for error webpages
4. What actions does JSP have? What are their roles?
A: JSP has the following 6 basic actions:
JSP:Include: Introduce a file when the page is requested.
JSP:Usebean: Find or instantiate a JavaBean.
JSP:Setproperty: Set attributes of JavaBean.
JSP:Getproperty: Outputs the attributes of a JavaBean.
JSP:Forward: Transfer the request to a new page.
JSP:Plugin: Generate an object or embed tag for the Java Plug-in based on the browser type
5. What is the difference between forward () and redirect () in Java Servlet APIs?
A: the former is only the redirection of control in the container, and the address after the redirection is not displayed in the address bar of the client browser. The latter is a complete redirection, And the browser will get the redirection address, and resend the request link. In this way, the link address after the jump is displayed in the address bar of the browser. Therefore, the former is more efficient. When the former can meet the needs, try to use the forward () method, and this will also help to hide the actual link. In some cases, for example, to jump to a resource on another server, you must use the sendredirect () method.
6. What is the difference between EJB and Java Bean?
A: Java Bean is a reusable component and there is no strict specification for Java Bean. 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, that is, distributed components. It is based on Java remote method call (RMI) technology, so EJB can be remotely accessed (cross-process, cross-computer ). However, 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. The EJB component is created and managed by the container. The customer accesses the real EJB component through the container.