/**
* By metaphy 2005-11-12
* Version: 0.01
* Note: The answer to the question comes from metaphy's previous knowledge or network. metaphy cannot guarantee its correctness or integrity and is only for reference.
**/
I. Basic Q &
1. Which of the following classes can be inherited?
Java. lang. Thread (T)
Java. lang. Number (T)
Java. lang. Double (F)
Java. lang. Math (F)
Java. lang. Void (F)
Java. lang. Class (F)
Java. lang. ClassLoader (T)
2. Differences between abstract classes and interfaces
(1) The interface can be multiple implements, and the abstract class can only be a single extends
(2) Only interfaces are defined. abstract classes can be defined and implemented.
(3) The default field definition of the interface is public static final. The default field of the abstract class is "friendly" (this package is visible)
3. Hashtable principle and differences between HashMap and Hashtable
HashTable principle: the storage location of a node is determined by the key code of the node, that is, the key code k of a given node, through a certain function relationship H (hash function ), obtain the function value H (k), which is interpreted as the storage address of the node.
HashMap is similar to Hashtable, but HashMap is non-synchronous (unsynchronizded) and can take null as the key code.
4. Difference between forward and redirect
Forward: an internal transfer in servlet
Redirect: redirection. There are two requests. The first attributs/parameters will be lost in 2nd requests.
5. What is a Web container?
Implement the web Protocol application in the J2EE specification. This Protocol defines the runtime environment of web programs, including concurrency, security, and lifecycle management.
6. Explain the following J2EE terms
(1) JNDI: Java Naming & Directory Interface, JAVA Naming Directory service. 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.
(2) JMS: Java Message Service, JAVA Message Service. It mainly implements communication between applications, including point-to-point and broadcast.
(3) JTA: Java Transaction API, JAVA Transaction Service. It provides various distributed Transaction services. The application only needs to call the interfaces it provides.
(4) JAF: Java Action FrameWork, JAVA Security Authentication FrameWork. It provides some security control frameworks for developers to implement their own personalized security control policies through various deployment and customization.
(5) RMI: Remote Method Interface, Remote Method call
7. What technologies are EJB implemented based on? The differences between SessionBean and EntityBean are also described. The differences between StatefulBean and StatelessBean are described.
EJB includes Session Bean, Entity Bean, and Message Driven Bean. It is implemented based on technology such as JNDI, RMI, and JAT.
SessionBean is used in J2EE applications to perform some server-side business operations, such as accessing the database and calling other EJB components. entityBean is used to represent the data used in the application system. for clients, SessionBean is a non-persistent object that implements some business logic running on the server. EntityBean is a persistent object, it represents an object view of an object stored in persistent storage, or an object implemented by an existing enterprise application.
Session Bean can be further subdivided into Stateful Session Bean and Stateless Session Bean. both Session beans can execute the system logic in method. The difference is that Stateful Session Bean can record the caller's status. Therefore, generally, A user has a corresponding Stateful Session Bean entity. although Stateless Session Bean is also a logical component, it is not responsible for recording the user status, that is, when the user calls Stateless Session Bean, the EJB Container does not find the entity of the specific Stateless Session Bean to execute this method. in other words, when several users execute a Stateless Session Bean's methods, they will execute the same Bean Instance. in terms of memory, compared with Stateful Session Bean and Stateless Session Bean, Stateful Session Bean consumes a large amount of memory on the J2EE Server, however, the advantage of Stateful Session Bean is that it can maintain the user's status.
8. XML Parsing Method
Sax, DOM, JDOM
9. What is Web Service?
Web Service is an interface proposed to enable communication and sharing between isolated sites.
Web services use unified and open standards on the Internet, such as HTTP, XML, SOAP (Simple Object Access Protocol), and WSDL, therefore, Web services can be used in any environment that supports these standards (Windows and Linux.
Note: The SOAP protocol (Simple Object Access Protocal) is an XML-based communication protocol used for network information exchange in distributed and distributed environments. Under this protocol, software components or applications can communicate through the standard HTTP protocol. Its design goal is simplicity and scalability, which facilitates the interoperability between a large number of heterogeneous programs and platforms, so that existing applications can be accessed by a wide range of users.
Advantages:
(1). cross-platform.
(2) the SOAP protocol is based on industry standards such as XML and HTTP and is supported by all important companies.
(3 ). because SOAP is used, data is transmitted in ASCII text instead of binary, which facilitates debugging. In this way, its data is easily transmitted through the firewall, the firewall does not need to create a "Vulnerability" for the program ".
(4). In addition, the technical difficulty of WebService implementation is much lower than that of CORBA and DCOM.
(5). To achieve B2B integration, EDI is relatively complete and complex, while WebService can be implemented at a low cost, and can be used by small companies.
(6) In the C/S program, WebService can deal with the server and retrieve the number of webpages without overall refreshing.
Disadvantages:
(1). WebService uses XML to encapsulate data, resulting in a large amount of data to be transmitted over the network.
(2) the WebService specification does not specify any implementation-related details, including the object model and programming language. This is not as good as that of CORBA.
10. 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.
11. What is the difference between dynamic INCLUDE and static INCLUDE in JSP?
Implement Dynamic INCLUDE with jsp: include action
It always checks changes in the contained files and is suitable for containing dynamic pages and can contain parameters
Static INCLUDE is implemented by using the include pseudo code and will not check the changes in the contained files. It is applicable to INCLUDE static pages.
Ii. Java programming and program running results
1. Java programming: print the current time of yesterday
public class YesterdayCurrent{
public void main(String[] args){
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -1);
System.out.println(cal.getTime());
}
}
2. Read and Write files to implement a counter
Public int getNum (){
Int I =-1;
Try {
String stri = "";
BufferedReader in = new BufferedReader (new FileReader (f ));
While (stri = in. readLine ())! = Null ){
I = Integer. parseInt (stri. trim ());
}
In. close ();
} Catch (Exception e ){
E. printStackTrace ();
}
Return I;
}
Public void setNum (){
Int I = getNum ();
I ++;
Try {
PrintWriter out = new PrintWriter (new BufferedWriter (new FileWriter (f, false )));
Out. write (String. valueOf (I); // it may be the cause of encoding. If int Is written directly, java encoding and windows encoding will be chaotic. Therefore, String is written here.
Out. c