Home Java JavaInterview questions javaweb interview questions (3)

javaweb interview questions (3)

Dec 13, 2019 pm 03:31 PM
java

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();

2. Create a new Http request

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

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

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

4, send an http request

XMLHttprequest.send(data);

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

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

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!

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

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is a deadlock in Java and how can you prevent it? What is a deadlock in Java and how can you prevent it? Aug 23, 2025 pm 12:55 PM

AdeadlockinJavaoccurswhentwoormorethreadsareblockedforever,eachwaitingforaresourceheldbytheother,typicallyduetocircularwaitcausedbyinconsistentlockordering;thiscanbepreventedbybreakingoneofthefournecessaryconditions—mutualexclusion,holdandwait,nopree

How to use Optional in Java? How to use Optional in Java? Aug 22, 2025 am 10:27 AM

UseOptional.empty(),Optional.of(),andOptional.ofNullable()tocreateOptionalinstancesdependingonwhetherthevalueisabsent,non-null,orpossiblynull.2.CheckforvaluessafelyusingisPresent()orpreferablyifPresent()toavoiddirectnullchecks.3.Providedefaultswithor

Java Persistence with Spring Data JPA and Hibernate Java Persistence with Spring Data JPA and Hibernate Aug 22, 2025 am 07:52 AM

The core of SpringDataJPA and Hibernate working together is: 1. JPA is the specification and Hibernate is the implementation, SpringDataJPA encapsulation simplifies DAO development; 2. Entity classes map database structures through @Entity, @Id, @Column, etc.; 3. Repository interface inherits JpaRepository to automatically implement CRUD and named query methods; 4. Complex queries use @Query annotation to support JPQL or native SQL; 5. In SpringBoot, integration is completed by adding starter dependencies and configuring data sources and JPA attributes; 6. Transactions are made by @Transactiona

Java Cryptography Architecture (JCA) for Secure Coding Java Cryptography Architecture (JCA) for Secure Coding Aug 23, 2025 pm 01:20 PM

Understand JCA core components such as MessageDigest, Cipher, KeyGenerator, SecureRandom, Signature, KeyStore, etc., which implement algorithms through the provider mechanism; 2. Use strong algorithms and parameters such as SHA-256/SHA-512, AES (256-bit key, GCM mode), RSA (2048-bit or above) and SecureRandom; 3. Avoid hard-coded keys, use KeyStore to manage keys, and generate keys through securely derived passwords such as PBKDF2; 4. Disable ECB mode, adopt authentication encryption modes such as GCM, use unique random IVs for each encryption, and clear sensitive ones in time

LOL Game Settings Not Saving After Closing [FIXED] LOL Game Settings Not Saving After Closing [FIXED] Aug 24, 2025 am 03:17 AM

IfLeagueofLegendssettingsaren’tsaving,trythesesteps:1.Runthegameasadministrator.2.GrantfullfolderpermissionstotheLeagueofLegendsdirectory.3.Editandensuregame.cfgisn’tread-only.4.Disablecloudsyncforthegamefolder.5.RepairthegameviatheRiotClient.

How to use the Pattern and Matcher classes in Java? How to use the Pattern and Matcher classes in Java? Aug 22, 2025 am 09:57 AM

The Pattern class is used to compile regular expressions, and the Matcher class is used to perform matching operations on strings. The combination of the two can realize text search, matching and replacement; first create a pattern object through Pattern.compile(), and then call its matcher() method to generate a Matcher instance. Then use matches() to judge the full string matching, find() to find subsequences, replaceAll() or replaceFirst() for replacement. If the regular contains a capture group, the nth group content can be obtained through group(n). In actual applications, you should avoid repeated compilation patterns, pay attention to special character escapes, and use the matching pattern flag as needed, and ultimately achieve efficient

Edit bookmarks in chrome Edit bookmarks in chrome Aug 27, 2025 am 12:03 AM

Chrome bookmark editing is simple and practical. Users can enter the bookmark manager through the shortcut keys Ctrl Shift O (Windows) or Cmd Shift O (Mac), or enter through the browser menu; 1. When editing a single bookmark, right-click to select "Edit", modify the title or URL and click "Finish" to save; 2. When organizing bookmarks in batches, you can hold Ctrl (or Cmd) to multiple-choice bookmarks in the bookmark manager, right-click to select "Move to" or "Copy to" the target folder; 3. When exporting and importing bookmarks, click the "Solve" button to select "Export Bookmark" to save as HTML file, and then restore it through the "Import Bookmark" function if necessary.

'Java is not recognized' Error in CMD [3 Simple Steps] 'Java is not recognized' Error in CMD [3 Simple Steps] Aug 23, 2025 am 01:50 AM

IfJavaisnotrecognizedinCMD,ensureJavaisinstalled,settheJAVA_HOMEvariabletotheJDKpath,andaddtheJDK'sbinfoldertothesystemPATH.RestartCMDandrunjava-versiontoconfirm.

See all articles