Interview: JavaWeb (13th); interview with javaweb
148. What are some disadvantages of AJAX?
Advantages:
1. The biggest difference is that the page is refreshing and the user experience is very good.
2. Use asynchronous mode to communicate with the server and provide more rapid response capabilities.
3. Some of the previous server workload can be transferred to the client, and the client's idle capabilities can be used to handle the workload, reduce the load on servers and bandwidth, and save space and bandwidth rental costs. In addition, it reduces the burden on the server. The ajax principle is to "retrieve data on demand", which can minimize the burden on the server caused by redundant requests and responses.
4. Based on standardized and widely supported technologies, you do not need to download plug-ins or applets.
Disadvantages:
1. ajax does not support browser back buttons.
2. Security Issues AJAX exposes the details of interaction with the server.
3. weak support for search engines.
4. destroys the abnormal mechanism of the program.
5. debugging is not easy.
149. What is the difference between AJAX applications and traditional Web applications?
In traditional Javascript programming, if you want to obtain information from a server database or file, or send the client information to the server, you need to create an HTML form and then GET or POST the data to the server. You need to click "Submit" to send or accept data information, and then wait for the server to respond to the request and reload the page.
Because the server returns a new page every time, traditional web applications may be slow and user interaction is unfriendly.
With AJAX technology, Javascript can directly interact with the server through the XMLHttpRequest object.
Through HTTP Request, a web page can send a Request to the web server and receive the information returned by the web server (you do not need to reload the page, the user feels that the page is refreshed, and does not see the request sending and receiving responses in the Javascript background. The experience is very good.
150. What is the Ajax implementation process?
(1) Create an XMLHttpRequest object, that is, create an asynchronous call object.
(2) create a new HTTP request and specify the method, URL, and authentication information of the HTTP request.
(3) set the function to respond to HTTP Request status changes.
(4) Send an HTTP request.
(5) obtain the data returned by the asynchronous call.
(6) use JavaScript and DOM for partial refreshing.
Specifically:
1. Create an XNLHttpRequest object
(Ignore ie) XMLHttpRequest request = new XMLHttprequest ();
2. Create a New Http Request
XMLHttprequest. open (method, url, flag, name, password );
3. Set the function to respond to Http request changes.
XMLHttprequest. onreadystatechange = getData;
Function getData (){
If (XMLHttprequest. readyState = 4 ){
Get Data
}
}
4. Send an http request
XMLHttprequest. send (data );
5. Get the objects returned by the asynchronous call
, Function (data ){
// After the asynchronous submission, the interaction succeeds. The returned data is the object returned by the asynchronous call, which is a string-type object.
}
6. Use js and DOM for partial refresh
MyDiv. innerHTML = ''This is the refreshed data''
151. What is the three paradigm of the database?
Paradigm 1: every field in the database table is inseparable
Second paradigm: the non-primary attribute in the database table only depends on the primary key
Third paradigm: There is no passing function dependency between non-primary attributes and keywords.
152. What is the Java Collection framework? What are the advantages of a collection framework?
Each programming language has a set. The original Java version contains several collection classes: Vector, Stack, HashTable, and Array.
With the widespread use of collections, Java1.2 proposes a set framework that includes all set interfaces, implementations, and algorithms. Java has been using generic and concurrent collection classes to ensure thread security for a long time. It also includes the blocking interfaces and their implementations in Java concurrent packet sending.
The Collection framework has the following advantages:
(1) Use core collection classes to reduce development costs, rather than implementing our own collection classes.
(2) With the use of strictly tested set framework classes, the code quality will be improved.
(3) use the collection classes attached to JDK to reduce code maintenance costs.
(4) reusability and operability.
153. What are the basic interfaces of the Java Collection framework?
Collection is the root interface at the Collection level. A set represents a group of objects, which are their elements. The Java platform does not provide any direct implementation of this interface.
SetIs a set that cannot contain repeated elements. This interface is used to model mathematical set abstraction, which is used to represent a set, just like a deck.
ListIs an ordered set that can contain repeated elements. You can access any element through its index. List is more like an array with dynamic length transformation.
MapIs an object that maps keys to values. A Map cannot contain duplicate keys: each key can only Map one value at most.
Some other interfaces include Queue, Dequeue, SortedSet, SortedMap, and ListIterator.
154. What are the advantages of generics in the Collection framework?
Java introduces generics, which are widely used by all set interfaces and implementations. Generics allow us to provide a type of object that can be accommodated for the set.
Therefore, if you add any element of another type, it will return an error during compilation. This avoids ClassCastException during runtime, because you will get an error message during compilation.
Generics also make the code clean and tidy. We do not need to use Explicit conversions and instanceOf operators. It also brings benefits to the runtime, because it does not produce bytecode instructions for Type checks.
155, what is the difference between Enumeration and Iterator interfaces?
Enumeration is twice faster than Iterator and uses less memory. Enumeration is very basic and meets the basic needs.
However, Iterator is more secure than Enumeration, because when a collection is being traversed, it will prevent other threads from modifying the collection.
The iterator replaces Enumeration in the Java Collection framework. The iterator allows callers to remove elements from the set, but Enumeration cannot. To make its functions clearer, the iterator method name has been improved.
156. What is the difference between Iterater and ListIterator?
1. We can use Iterator to traverse Set and List sets, while ListIterator can only traverse List.
2. Iterator can only traverse forward, while LIstIterator can traverse in two directions.
3. ListIterator inherits from the Iterator interface, and then adds some additional functions, such as adding an element, replacing an element, and obtaining the index location of the first or second element.
157. How do we sort a group of objects?
If we need to sort an object array, we can use the Arrays. sort () method. To sort an object list, we can use the Collection. sort () method.
Both classes are used for natural sorting (using Comparable) or standard-based sorting (using Comparator) overload Methods sort ().
Collections uses the array sorting method internally, all of which have the same performance, but Collections takes time to convert the list to an array.
158. What are the best practices related to the Java Collection framework?
1. Select the correct set type as needed. For example, if the size is specified, we use Array instead of ArrayList. If we want to traverse a Map in the insert sequence, we need to use TreeMap. If we do not want to repeat it, we should use Set.
2. Some collection classes allow you to specify the initial capacity, so if we can estimate the number of storage elements, we can use it to avoid re-hash or size adjustment.
3. Interface-based programming, rather than implementation-based programming, allows us to easily change the implementation later.
4. Type-safe generic is always used to avoid ClassCastException during runtime.
5. Use the unchangeable class provided by JDK as the Map key to avoid self-Implementation of hashCode () and equals ().
6. Use the Collections tool class as much as possible, or obtain a set of read-only, synchronous, or null, rather than writing your own implementations. It will provide code reusability, and it has better stability and maintainability.
159. What is a transaction ?,
Transactions are the basic unit of recovery and concurrency control.
Four basic features of transactions
Atomicity, consistency, isolation, and Durability
Atomicity is similar to consistency, meaning either all succeed or fail.
Consistency refers to the process from one consistent state to another consistent state.
Isolation means that a transaction cannot be disturbed by another transaction during execution.
Durability means that once a transaction is committed, its changes to the data in the database should be permanent and cannot be changed.(Here is just a brief explanation of the interview, and a detailed understanding of the problem)
160. What problems have you encountered during development? How can this problem be solved?
Pawn .......