Java interview questions collection

Source: Internet
Author: User

Cookiee session differences
1. Client Server
2. The session browser is disabled and the cookiee validity period can be set.

Dirty dB read, which can be configured for hosting transactions in spring/CodeThe SQL standard defines four isolation levels

1 dirty read. One transaction is unique to the data that has not been committed but has been saved by another transaction.

2 read commited: a transaction can only read all the data that has been committed. MVCC MySQL InnoDB's Repeatable read does not guarantee the avoidance of phantom read. The application must use the lock read to ensure that. The locking mechanism is next-key locks.

Select * from child where ID <100 for update; locks less than 100 of data and queues other transactions

3 Repeatable read (Repeatable read): Select always returns the data at the beginning of the transaction, suitable for concurrent reading, but may produce phantom read. When updating, which is inconsistent with the data found

4 serializable forces transaction sorting, making it impossible to conflict with each other, which may be efficient.

Exception category

1 throwable class is the superclass of all errors or exceptions in the Java language (this is what can be thrown ). It has two subclasses: Error and exception. There are two types of exceptions: checkedexception and uncheckedexception.

The main difference between the two types of exceptions is that checkedexception must be captured by try... catch..., while uncheckedexception does not need to be captured.

2. The error class object is generated and thrown by the Java Virtual Machine. The exception class object is generated and thrown by the application.ProgramProcessing or throwing an error indicates that the restoration is not an impossible but difficult case. For example, memory overflow. It is impossible to expect the program to handle such a situation.

3. If it is a running exception, we do not need to try the Catch Block, because we do not know how to handle this exception to ensure the normal operation of the program. If an exception is checked, we need to handle the exception. Since the exception is checked,

We should already have a solution to handle this exception, so we need to use try catch to handle this exception to ensure that the program runs.

Io NiO
Http://blog.csdn.net/showwair/article/details/7488523
Http://furturestrategist.iteye.com/blog/1463369

Sendredirect response. Redirect jump
1 sendredirect client jump, the client sends two requests, the final address shows the jump address
2 response. Redirect server jump, the client sends a request, the final display address is the initial request address
Requestdispatcher reqdispatcher = request. getrequestdispacher ("");
Reqdispatcher. Forward (request, response)

Comparison

"=" Compares the values of the two variables, that is, the first address of the two objects in the memory.
"Equals ()" compares whether the content in the string is the same.

 

Struts prevents repeated submission

1. <s: token/> generates a hidden input box for the guid value and places the guid in the session. Before executing the action, the "token" interceptor compares the session token with the request token. If the two are the same,

Delete the token in the session and execute it. Otherwise, add the error message to actionerrors.

<% @ Tag-lib uri = "/Struts-tags" prefix = "S" %>

<S: Form Action = "tokenaction"> <s: textfield name = ""/> <s: token/> <input type = "Submit" value = "send"/> </S: Form>

2 struts2 has two interceptions to prevent repeated form submission: token and tokensession. The tokensession inherits the token. Generally, the tokensession client is friendly,

Because if tokensession is submitted repeatedly, the error. jsp page is not displayed.

<Action name = "tokenaction" class = ""> <Interceptor-ref name = "defaultstack"/> <Interceptor-ref name = "token"/>

<Result name = "invalid. Token">/WEB-INF/notfirstsubmit. jsp </result>

</Action>

Difference between map set collection
1. array is the most efficient method for all Java "Storage and random access to a series of objects. The disadvantage is that the number of elements in the array cannot be determined. The length only tells us the size of the array.
2 Collection contains list and set. list stores data in a specific order. Set data cannot be duplicated. Set can only traverse elements through itorator, and get () can be used for list ();
3. List contains arraylist, hidden list, and vector (including stacks). To quickly insert and delete elements, use the hidden list
4. map contains hashmap, hashtable, and treemap. hashmap is the fastest. hashmap is similar to hashtable. The difference is that hashmap is non-synchronous and allows null.

What is Servlet?
Wrap the servlet into standardwrapper in the context container. standardwrapper is a part of the Tomcat container and has the characteristics of the container,
Servlet should not be strongly coupled in Tomcat for an independent web development standard. Standardwrapper is added to the context as a sub-container,
All other web. xml attributes are parsed to the context. Therefore, the context container is the servlet container that truly runs the servlet.
If the Servlet's load-on-startup configuration item is greater than 0, it will be instantiated when the context container is started. As mentioned above, it will read the default globalwebxml when parsing the configuration file,
Some default configuration items are defined in the web. xml file under Conf, which defines two servlets: org. Apache. Catalina. servlets. DefaultServlet
And org. Apache. Jasper. servlet. jspservlet. Their load-on-startup values are 1 and 3 respectively, that is, when Tomcat is started, these two servlets will be started.
The method for creating a servlet instance starts with wrapper. loadservlet. To complete the loadservlet method, obtain the servletclass and hand it to instancemanager.
Create an object based on servletclass. Class. If JSP-file is configured for this servlet, this servletclass is defined in CONF/Web. xml.
Org. Apache. Jasper. servlet. jspservlet.
Servlet can indeed help us complete all the work, but currently few web applications use servlet to directly interact with all pages, but adopt a more efficient MVC framework.
What JSP? What is the relationship with Servlet? JSP is an extension of servlets technology. Everything that jsp can do can be done by servlet. However, JSP allows you to easily mix Java code with the HTML language and complete powerful functions. This allows you to easily read the code and view the program execution results in a browser.
When a JSP file is accessed for the first time, it is converted to the Java Servlet Source code and then compiled into a Java bytecode. Work stores the class file generated after JSP compilation.

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.