Home > Java > JavaInterview questions > javaweb interview questions (3)

javaweb interview questions (3)

(*-*)浩
Release: 2019-12-13 15:31:37
Original
2314 people have browsed it

javaweb interview questions (3)

What are the advantages and disadvantages of AJAX?

Advantages:

1. The biggest point is that the page does not refresh, and the user experience is very good.                                                                                                                                                                                                                              (Recommended Learning: java Interview Questions)

2. Use asynchronous mode to communicate with the server, with a faster response capability.

3. Some of the work previously burdened by the server can be transferred to the client, using the idle capacity of the client to process it, reducing the burden on the server and bandwidth, and saving space and broadband rental costs. And to reduce the burden on the server, the principle of ajax is to "fetch data on demand", which can minimize the burden on the server caused by redundant requests and responses.

4. Based on standardized and widely supported technology, there is no need to download plug-ins or small programs.

Disadvantages:

1. Ajax does not support the browser back button.

2. Security issues AJAX exposes the details of interaction with the server.

3. The support for search engines is relatively weak.

4. Destroyed the exception mechanism of the program.

5. It is not easy to debug.

What is the difference between AJAX applications and traditional Web applications?

In traditional Javascript programming, if you want to get information from a server-side database or file, or send client information to the server, you need to create an HTML form and then GET or POST the data to the server. end.

Users need to click the "Submit" button to send or receive data information, and then wait for the server to respond to the request and the page to reload.

Because the server returns a new page every time, traditional web applications may be slow and user-unfriendly.

Using AJAX technology, Javascript can interact directly with the server through the XMLHttpRequest object.

Through HTTP Request, a web page can send a request to the web server and accept the information returned by the web server (without reloading the page). The same page is still displayed to the user. The user feels that the page is refreshed. Also see There is no need to go to the Javascript background to send requests and receive responses, and the experience is very good.

What is the implementation process of Ajax?

(1) Create an XMLHttpRequest object, that is, create an asynchronous call object.

(2) Create a new HTTP request, and specify the method, URL and Verify information.

(3) Set the function to respond to HTTP request status changes.

(4) Send HTTP request.

(5) Get the data returned by the asynchronous call.

(6) Use JavaScript and DOM to implement partial refresh.

To be more specific:

1, create an XNLHttpRequest object

(不考虑ie)XMLHttpRequest request = new XMLHttprequest();
Copy after login

2. Create a new Http request

XMLHttprequest.open(method,url,flag,name,password);
Copy after login

3, set the function to respond to changes in the Http request

XMLHttprequest.onreadystatechange=getData;
function getData(){
    if(XMLHttprequest.readyState==4){
        //获取数据
    }
}
Copy after login

4, send an http request

XMLHttprequest.send(data);
Copy after login

5, and obtain the object returned by the asynchronous call ,

function(data){
//异步提交后,交互成功,返回的data便是异步调用返回的对象,该对象是一个string类型的
}
Copy after login

6, use js and DOM to achieve partial refresh

myDiv.innerHTML=''This is the refreshed data''

Let’s briefly talk about the database The three paradigms?

First normal form: Every field in the database table is indivisible

Second normal form: The non-primary attributes in the database table only depend on the primary key

Third normal form: There is no transitive function dependency between non-primary attributes and keywords

What is the Java collection framework? Name some advantages of collection framework?

There are collections in every programming language. The initial version of Java included several collection classes: Vector, Stack, HashTable and Array.

With the widespread use of collections, Java1.2 proposes a collection framework that includes all collection interfaces, implementations and algorithms. Java has been going through the process of using generics and concurrent collection classes while ensuring thread safety for a long time. It also includes blocking interfaces and their implementations in the Java concurrency package.

Some advantages of the collection framework are as follows:

(1) Use core collection classes to reduce development costs instead of implementing our own collection classes.

(2) With the use of rigorously tested collection framework classes, code quality will be improved.

(3) Code maintenance costs can be reduced by using the collection classes that come with the JDK.

(4) Reusability and operability.

What are the basic interfaces of the Java collection framework?

Collection is the root interface of the collection level. A collection represents a set of objects that are its elements. The Java platform does not provide any direct implementation of this interface.

Set is a collection that cannot contain duplicate elements. This interface models a mathematical set abstraction and is used to represent sets, like a deck of cards.

List is an ordered collection that can contain repeated elements. You can access any element by its index. List is more like an array whose length changes dynamically.

Map is an object that maps keys to values. A Map cannot contain duplicate keys: each key can only map at most one value.

Some other interfaces are Queue, Dequeue, SortedSet, SortedMap and ListIterator.

What are the advantages of generics in collection framework?

Java1.5 introduced generics, and all collection interfaces and implementations use them extensively. Generics allow us to provide a collection with an object type that it can hold.

So if you add any element of other type, it will error when compiling. This avoids ClassCastException at runtime, since you will get an error message at compile time.

Generics also make the code cleaner, we don’t need to use explicit conversions and instanceOf operators. It also brings benefits to the runtime because no type-checked bytecode instructions are generated.

What is the difference between Enumeration and Iterator interfaces?

Enumeration is twice as fast as Iterator and uses less memory. Enumeration is very basic and meets basic needs.

However, compared with Enumeration, Iterator is safer because when a collection is being traversed, it will prevent other threads from modifying the collection.

Iterator replaces Enumeration in Java collection framework. Iterators allow the caller to remove elements from a collection, while Enumeration cannot. Iterator method names have been improved to make its functionality clearer.

What is the difference between Iterater and ListIterator?

1. We can use Iterator to traverse Set and List collections, while ListIterator can only traverse List.

2, Iterator can only traverse forward, while LIstIterator can traverse in both directions.

3, ListIterator inherits from the Iterator interface, and then adds some additional functions, such as adding an element, replacing an element, and getting the index position of the previous or following element.

How do we sort a set of objects?

If we need to sort an array of objects, we can use the Arrays.sort() method. If we need to sort a list of objects, we can use the Collection.sort() method.

Both classes have overloaded method sort() for natural sorting (using Comparable) or criteria-based sorting (using Comparator).

Collections internally use the array sorting method, so both of them have the same performance, except that Collections takes time to convert the list into an array.

What are the best practices related to Java Collections Framework?

1. Select the correct collection type as needed. For example, if size is specified, we will use Array instead of ArrayList. If we want to traverse a Map based on insertion order, we need to use a TreeMap. If we don't want to repeat, we should use Set.

2, some collection classes allow specifying the initial capacity, so if we can estimate the number of stored elements, we can use it and avoid rehashing or resizing.

3, based on interface programming rather than implementation programming, which allows us to easily change the implementation later.

4, always use type-safe generics to avoid ClassCastException at runtime.

5. Use the immutable class provided by JDK as the key of Map to avoid implementing hashCode() and equals() yourself.

6, use the Collections tool class as much as possible, or get a read-only, synchronized or empty collection instead of writing your own implementation. It will provide code reusability, and it will have better stability and maintainability.

What is a transaction?

Transaction is the basic unit of recovery and concurrency control

The four basic characteristics of transaction

Atomicity, consistency, isolation, durability

Atomicity is almost the same as consistency, which means that either everything succeeds or fails

Consistency means that from one consistency state to another consistency state

Isolation is It is said that the execution of a transaction cannot be interfered by another transaction

Persistence means that once a transaction is submitted, its changes to the data in the database should be permanent and cannot be changed (this is just a simple interview) Understand it at once, ask Du Niang for detailed understanding)

The above is the detailed content of javaweb interview questions (3). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template