The difference between forwarding and redirecting and common interview questions

Forwarding is server behavior, redirection is client behavior

1. Forwarding is done on the server side; redirection is done on the client side

2. The speed of forwarding is fast; the speed of redirection is slow

3. Forwarding is the same request; redirection is two different requests

4. Forwarding will not execute the code after the forwarding; redirection will execute the code after the redirection

5. The forwarding address bar has not changed; the redirecting address bar has changed

6. Forwarding must be done under the same server; redirection can be done under different servers

The statements to call forwarding and redirection in servlet are as follows:

request.getRequestDispatcher("new.jsp").forward(request,
response);//转发到new.jsp

response.sendRedirect("new.jsp");//Redirect to new.jsp

What is the mechanism for implementing polymorphism in java?

Overriding and overloading of methods are different manifestations of Java polymorphism. Overriding Overriding is a manifestation of polymorphism between parent and child classes, and overloading Overloading is a manifestation of polymorphism in a class.

Is String the most basic data type?

Basic data types include byte, int, char, long, float, double, boolean, and short. The java.lang.String class is final, so it cannot be inherited or modified. In order to improve efficiency and save space, we should use the StringBuffer class

Is it possible to include multiple classes (not inner classes) in one ".java" source file? What are the restrictions?

Can. Only one class name must be the same as the file name.

How many types of streams are there in java? JDK provides some abstract classes for each type of stream for inheritance, please name them which classes are?

 Byte stream, character stream. Byte stream inherits from InputStream OutputStream, and character stream inherits from InputStreamReader OutputStreamWriter. There are many other streams in the java.io package, mostly for performance and ease of use.

What are the characteristics of the three interfaces List, Map, and Set when accessing elements?

List holds elements in a specific order, and can have repeating elements. Set cannot have duplicate elements, internal sorting. Map saves the key-value value, and the value can be multi-valued.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324682927&siteId=291194637