Gold three silver Four Java interview Clearance Essentials Summary set (Daniel Induction)

Source: Internet
Author: User
Tags aop driver database finally block memcached modifier

Java Interview Essentials Summary set (partial answers)
Description
If you're lucky enough to see it,

1, the overall framework of this article from @ Ali Liang's blog, summed up very good. Worthy of our study, its blog part of the answer.
2, because of their limited ability, failed to achieve the mind that idea, is the first time to write their own, the second time book query
3, the article will be put on GitHub, with Git control. Could be an ongoing station.
3, if there is a similar, purely accidental. You will be put on the link. If you have a spelling error, please understand.
4, the test put to the last side, interested can see? Can I get started with this?
5. Hard drive---two---
6, hands-on, clothed. After watching others to know how big the gap. GoGoGo.
7, follow-up first not updated, at present in the project to do the actual combat, I find a job, their own independent thinking summary share to everyone.

Basic article
Basic
1. Object-oriented feature reference
(1) Encapsulation: is to encapsulate the objective things into abstract classes, and the class can put their own data and methods only let the trusted object operation, the non-trusted information hiding. Simply put, a class encapsulates the data and the code logical entities that manipulate the data. Within a class, the method or data can be private and inaccessible to the outside world. The purpose of this is to protect the internal data at different levels, preventing the wrong use of the private part of the object.
(2) Inheritance: It can use all the functions of an existing class and extend these functions on the original basis. Creating a new class from inheritance is called a subclass or derived class. The classes that are inherited are called "base classes" and "parent class" or "superclass". To implement inheritance, you can inherit and combine (aggregate): Implement inheritance and interface inheritance. Implementing inheritance is the ability to directly use the properties and methods of the base class without additional coding; Interface inheritance refers to the use of only the names of properties and methods, but subclasses must provide the ability to implement them.
(3) Polymorphism: Refers to a class instance of the same method in different situations have different performance. A polymorphic mechanism makes it possible for an object with different internal structures to share an external interface. Although specific actions are different for different objects, they can be invoked in the same way through a common class.
The most common polymorphism is to pass a subclass into the parent class parameter, and when the runtime invokes the parent class method, it determines the specific internal structure or behavior through the passed-in subclass.
2, the object-oriented Five principles:

(1) Single duty Principle (Single-resposiblity-principle): A class should have only one cause for it to change
(2) Open closure principle (open-closed-principle): Open to expansion, closed for changes
(3) Richter replacement principle (Liskov-substituion Principle): Subclasses can replace the parent class, and appear anywhere the parent class can appear. GOF advocates interface-oriented programming
(4) interface Isolation principle (Interface-segregation Principle): Using multiple interfaces is much better than using a single interface.
(5) Dependency inversion principle (dependecy-invarsion Principle): Let high-level modules do not rely on low-layer modules.

3, final, finally, finalize the difference reference
1, final modifier (keyword)
Final is used to control whether a member, method, or a class can be overridden or inherited.
(1), if the class is declared final, it means that it cannot be derived from a new subclass and cannot be inherited as a parent class.
(2), the variable or method is declared final, you can guarantee that they will not be changed in use, its initialization can be in two places:

Assign a value directly to the final definition,
In constructors, the two can only be selected, and can only be read in future references, not modifiable

2. Finally (for exception handling)
Typically used in exception handling, a finally block is provided to perform any clear operation, and the try{}catch{}finally{}.finally structure keeps the block of code from executing, regardless of whether or not an exception occurs. Enables finally to maintain the internal state of the object and to clean up non-memory resources. Used to close a read or write operation on a file or close a database connection operation.
3. Finalize (for garbage collection)
Finalize this is the method name. In Java, it is allowed to use the Finalize () method to do the necessary cleanup before the garbage collector cleans objects out of memory. This method is called by the garbage collector to this object when it determines that the object is not referenced. It is defined in object. Therefore, all classes inherit it, and the Finalize method is called on the object before the garbage collector deletes the object.
4. What is the difference between int and Integer reference
The biggest difference between the two is that the difference between the basic type and the wrapper class is the big way.
An int is a primitive type that directly saves a value, and an integer is an object that points to the object with a reference.
Data types in Java are divided into basic data types and complex data types
int is the former, and Integer is the latter (is a class), and when initialized, the variable of int is initialized to 0, and the Interger variable is initialized to null.
5. The difference between overloading and rewriting "reference
Overloading (overload)
(1), method overloading is a means for a class to handle synchronous type data in a uniform manner. Multiple functions with the same name exist at the same time, with different number of parameters and types. Overloading (overload) is a representation of polymorphism in a class.
(2), the overloading of Java methods, is that you can create multiple methods in a class, they have the same name, but have different parameters, as well as definitions. The method is called by the number of different arguments passed to them and the parameter type to determine the specific use of that method, which is polymorphic.
(3), when overloaded, the method name is the same, but the parameter type and the number of different, the return value type can be the same, or can be different. Cannot use return value as the distinguishing criterion for overloaded functions
Override (Override)
(1), the polymorphism between the parent class and the subclass, redefining the function of the parent class. If a subclass defines a method that has the same method name and parameter as the parent class, we say that the method is overridden (override). In Java, subclasses can inherit methods from the parent class without rewriting the same method, but sometimes the subclasses do not want to inherit the parent class method intact, but want to make some modifications, This requires method overrides, which are also called method overrides.
(2), the method in the Kawai class has the same name, return value, and argument list as a method of the parent class, and the new method overwrites the original method. If you want the original method in the parent class, you can use the Super keyword, which references the parent class of the current class.
(3), the access adornment permission of the subclass function can not be less than the parent class.
The difference between the two is:
Overriding polymorphism works, and calling overloaded methods can greatly reduce the amount of code input, and the same method name can have different functions or return values as long as it passes different parameters inside.
6. What is the difference between abstract class and interface reference
Abstract classes are used to capture the generic properties of subclasses. It cannot be instantiated and can only be used as a superclass of subclasses. Abstract classes are templates that are used to create subclasses in the inheritance hierarchy.
An interface is a collection of abstract methods that, if a class implements an interface, inherits the abstract method of the interface. It's like a contract pattern. If you implement this interface, you must ensure that you use these methods. An interface is just a form, and the interface itself cannot do anything.

Parameters
Abstract class
Interface

The default method implementation
It can have the default method implementation
The interface is completely abstract and there is no implementation of the method at all

Realize
Subclasses use the extends keyword to inherit abstract classes
Subclasses use implements to implement interfaces

Constructors
Abstract classes can have constructors
Interfaces cannot have constructors

Modifier accessors
Abstract methods can have public,protected, and default
Interface method default modifier is public

Multiple inheritance
An abstract method can inherit a class or implement multiple interfaces
An interface can inherit only one or more other interfaces

When to use abstract classes and interfaces

1. If you have some methods to make some of them default implementations, then use abstract classes.
2, if you want to achieve multiple inheritance, then you must use the interface. Because Java does not inherit much, subclasses cannot inherit multiple classes, but can implement multiple interfaces
3, if the basic ability is constantly changing, then you need to use abstract classes. If you constantly change the basic functionality and use the interface, you need to change all classes that implement the interface.

Default methods in JDK 8
A default method and a static method are introduced into the interface to reduce the difference between the abstract class and the interface. Now we can provide a way for the interface to implement the default implementation, without forcing it to implement it.
7, talk about the use of reflection and implementation of recommendations to see
The Java reflection mechanism is a very powerful feature that can be seen in many projects such as Spring,mybatis. Through the reflection mechanism, we can get the type information of the object during run time. With this we can implement design patterns such as Factory mode and proxy mode, but also solve the vexing problems such as Java generic erasure.
Gets the reflection class for an object, and in Java there are three ways to get a reflection class for an object.

Through the GetClass () method
Through the Class.forName () method;
Use Class. class
Implemented by the ClassLoader, getClassLoader ()

8, talk about the custom annotation scene and implementation recommendations, podcasts are recommended
Tracking the dependencies of the code, implementing the function of replacing the configuration file. It is more common to note-based configurations in frameworks such as spring.
You can also generate documents for common @[email protected] @return and so on. such as @override in the method signature, if this method does not overwrite the superclass method, the compile time can be checked out. Br/> automatically inherits the Java.lang.annotation.Annotation interface when using @interface custom annotations, and other details are automatically completed by the compiler, and other annotations or interfaces cannot be inherited when annotations are defined.

In the request-response between the client and the server, the two most commonly used methods are: GET and POST.

GET-Requests data from the specified resource.
POST-submits the data to be processed to the specified resource

Get method
Note that the query string (name/value pair) is sent in the URL of the GET request:
/test/demo_form.asp?name1=value1&name2=value2

Requests can be cached
Request remains in browser history
Requests can be bookmark-Favorites
The request should not be used when processing sensitive data
Request has a length limit
Requests should only be used to retrieve data

Post method
Note that the query string (name/value pair) is sent in the HTTP message body of the POST request:
Post/test/demo_form.asp http/1.1
Host:w3schools.com
Name1=value1&name2=value2
Compare GET to POST

Method
GET
POST

Cache
can be cached
Cannot be cached

Encoding type
application/x-www-form-urlencoded
Application/x-www-form-urlencoded or Multipart/form-data. Use multiple encodings for binary data.

Limits on the length of data
Yes. The GET method adds data to the URL when the data is sent, and the length of the URL is restricted (the maximum URL length is 2048 characters)
Unlimited.

Restrictions on data types
Only ASCII characters are allowed
There is no limit. Binary data is also allowed.

Security
GET is less secure than POST because the data being sent is part of the URL. Never use GET when sending passwords or other sensitive information
POST is more secure than GET because parameters are not saved in the browser history or Web server logs.

Visibility of
The data is visible to everyone in the URL.
The data is not displayed in the URL.

Other HTTP Request Methods

HEAD is the same as GET, but returns only the HTTP header and does not return the document body.
The PUT upload specifies the URI representation.
Delete Deletes the specified resource.
OPTIONS returns the HTTP methods supported by the server
Connect converts the request connection to a transparent TCP/IP channel.

10, session and the difference between the cookie reference, good with 1-5 work experience, in the face of the current popular technology do not know where to start, the need to break through the technical bottleneck can add group. Stay in the company for a long time, have a very comfortable, but job-hopping interview wall. Need to study in a short period of time, job-hopping to get a high salary can add group. If there is no work experience, but the foundation is very solid, on the Java work mechanism, common design ideas, Common Java Development Framework Master skilled can add group. Java Architecture Group: 5,825,056,431 communication.

The cookie data is stored on the client's browser and the session data is placed on the server.
Cookies are not very secure and others can analyze cookies stored locally and make cookie spoofing taking into account that security should use the session.
The session will be saved on the server for a certain amount of time. When the increase in access, will be compared to the performance of your server to reduce the performance of the server, you should use cookies.
A single cookie cannot hold more than 4K of data, and many browsers limit a maximum of 20 cookies per site.
So personal advice:
Storing important information such as login information as session
Additional information can be placed in a cookie if it needs to be retained

11, Session distributed processing reference, good
First type: Sticky session
Sticky session refers to the user locked to a server, such as the above example, the first time the user requests, the load balancer forwarded the user's request to a server, if the load Balancer set sticky session, then the user each subsequent request will be forwarded to a server, Equivalent to the user and a server glued to a piece, this is the sticky session mechanism
The second type: Server session replication
Principle: The session on any server is changed (modified), the node will serialize all the contents of this session, and then broadcast to all other nodes, regardless of the other server need not session, in order to ensure that the session synchronization.
The third type: Session sharing mechanism
Use distributed caching schemes such as memcached, Redis, but require memcached or Redis to be a cluster.
Principle: Different tomcat specifies access to different master memcached. The information between multiple memcached is synchronous, and can be backed up and highly available. When the user accesses, the session is created in Tomcat first, and then the session is copied to its corresponding memcahed.
Fourth: Session persistence to Database
Principle: Don't say more, come up with a database, dedicated to storing session information. Keep the session persistent. Pros: Server problems, the session will not lose the disadvantage: if the site is a large number of visits, the session stored in the database, the database will be a great pressure, but also need to add additional overhead to maintain the database.
The fifth kind of terracotta implements session replication
Principle: Don't say more, come up with a database, dedicated to storing session information. Keep the session persistent. Advantages: Server problems, the session will not lose the disadvantage: if the site is a large number of visits, the session stored in the database, the database will cause great pressure, but also need to increase the additional overhead to maintain the database
12. JDBC Process
Note: All objects used should be set to NULL before
(1) To register driver database driver for DriverManager class,
Class.forName ("Com.somejdbcvendor.TheirJdbcDriver");
(2) Call the Drivermanager.getconnection method, obtain the database connection connection object through the JDBC URL, user name, password.
Connection conn = Drivermanager.getconnection (
"Jdbc:somejdbcvendor:other data needed by some JDBC vendor",//url
"MyLogin",//user name
"MyPassword"); Password
(3) After acquiring connection, you can create statement with Createstatement to execute the SQL statement. Here is an example of inserting (insert):
Statement stmt = Conn.createstatement ();
Stmt.executeupdate ("INSERT into MyTable (name) VALUES (' My Name ')");
(4) Sometimes get query results, such as SELECT, get query results, query (SELECT) results are stored in the result set (ResultSet).
ResultSet rs = stmt.executequery ("SELECT * from MyTable");
(5) Close the database statement and close the database connection.
Rs.close ();
Stmt.close ();
13. MVC Design Idea
Every time a user clicks a link or submits a form in a Web browser, the request begins to work. The request is a very busy guy, from the start of the browser to get the response back, it will go through a lot of stations, at each station will leave some information, but also bring some information.

The Spring Workflow Description text is here

The user sends a request to the server, and the request is captured by the spring front control servelt Dispatcherservlet;

Dispatcherservlet parses the request URL to get the request Resource Identifier (URI). Then, according to the URI, call handlermapping to get all the related objects of the handler configuration (including the handler object and the interceptor corresponding to the handler object), and finally return as a Handlerexecutionchain object;

Dispatcherservlet according to the obtained handler, choose a suitable handleradapter. (Note: If Handleradapter is successfully obtained, the Interceptor Prehandler (...) will start executing. Method

Extract the model data from the request, populate the handler entry, and start executing the handler (Controller). In the process of populating the handler, depending on your configuration, spring will do some extra work for you:

Httpmessageconveter: Converts a request message (such as JSON, XML, and so on) into an object, converting the object to the specified response information
Data transformation: Data conversion for a request message. such as string conversion to Integer, double, etc.
Data is initialized: Data is formatted for the request message. such as converting a string into a formatted number or a formatted date
Data validation: Verifying the validity of the data (length, format, etc.), and verifying that the results are stored in Bindingresult or error

Handler returns a Modelandview object to Dispatcherservlet when execution is complete;

Based on the returned Modelandview, select a suitable viewresolver (must be viewresolver already registered in the spring container) to return to Dispatcherservlet;

Viewresolver combining model and view to render the view

Returns the rendered result to the client.


Picture reference here

Spring Workflow Description

Why does spring use only one servlet (Dispatcherservlet) to handle all requests?
Detailed view of the Java EE design mode-front-end control mode
Why does spring use handlermapping and Handleradapter to deal with handler?
Conforms to the single-object-oriented principle of responsibility, code architecture is clear, easy to maintain, and most importantly, code reusability is high. such as handleradapter may be used to handle a variety of handler.

1. The first stop of the journey is Spring's dispatcherservlet. Like most Java-based web frameworks, Spring MVC all requests pass through a front-end controller (front Contrller) Servlet. The front-end controller is a common Web application pattern. Here a single-instance servlet will request delegates to other components of the application to perform the actual processing. In spring MVC, Dispatcherservlet is the front controller.
2. Dispactcher's task is to send the request to the spring MVC Controller. The controller is a spring component that handles requests. There may be multiple controllers in a typical application, and dispatcherservlet need to know which controller to send the request to. So Dispactcher will query one or more processor mappings (Handler mapping) to determine where the next station is requested. The processing mapper makes decisions based on the URL information that the request carries.
3. Once the appropriate controller is selected, Dispatcherservlet will send the request to the selected controller. To the controller, the request unloads its payload (user-submitted information) and waits patiently for the controller to process the information. (In fact, a well-designed controller itself deals with little or no work, but instead delegates the business logic to one or more server objects for processing)
4, the controller after the completion of processing logic, usually generates some information. This information needs to be returned to the user and displayed on the browser. This information is called the model, but simply returning the original information to the user is not enough----the information needs to be formatted in a user-friendly way, usually HTML. So, the information needs to send a view, usually a JSP.
5. The last thing the controller does is to package the model and show the name of the view used to render the output. It then sends the request back to Dispatcherservlet, along with the model and view.
6, thus, * the controller will not be coupled with a specific viewthe name of the view passed to the controller does not directly represent a particular JSP. In fact, it is not even certain that the view is a JSP. Instead, it simply passes a logical name that will be used to find the real view that produces the result. Dispatcherservlet will use the view resolver to match the logical view name to a specific view implementation, which may or may not be a JSP
7, although Dispatcherservlet already know which drive into the rendering results, the request of the task is basically completed, its last stop is trying to achieve. Here it is delivered to the model data. The requested task is over. The view renders the output using model data. This output is passed to the client via the Response object (not hard-coded as it sounds)
As you can see, the request takes a number of steps to eventually form a response back to the client, and most of the steps are done inside the SPIRNG framework.
14, equals and = = Difference Reference

1, use = = Compare native types such as: boolean, int, char, etc., use equals () to compare objects.
2, = = Returns true if two references point to the same object, the return result of equals () depends on the specific business implementation
3. Comparison of strings use Equals () instead of = = operator
The main difference is that one operator is a method, = = is used to compare primitive types and the Equals () method compares the equality of objects.

Interested can see my answer, no comparison will not hurt.
1. Soft power
1. Tell me about your highlights
Before a person to take Chuan Zang line, Qinghai-Tibet line. When the early morning stood in the square of the Potala Palace, what kind of accomplishment can not be likened to, only experienced people can understand. Experienced the bottom of life, to the border Yunnan, also went to the North Hangzhou. Experience the Tramp's experience of letting the bunks go. Let me have a new understanding of the world. (Here just to remind the interviewer I have perseverance, not afraid of hardship, the quality of kindness)
Technical: At present, there is no experience to solve the major problems. There is a continuous learning heart (English is very important, very important, very important). You'll develop a habit of blogging in the future, and mingle with GitHub.
2. Tell me what book you are reading recently
"Spring Combat", this book is very good, in-depth elaboration of Spring's IOC and AOP features. Explains the components commonly used in the spring ecosystem. Combined with the author's github code example, learning works well.
The next one will be "Spring boot combat"
The next one will be "Netty combat" to see the first chapter on the deep obsession.
3. Talk about the technical books that you think are most meaningful
Personally think that xxx is how xx (Japanese). XXX Combat series. XXX authoritative guide, domestic in-depth xxx is also good. There are some books on the bottom of the computer.
4. What to do after work
At present, there is no work, except study or study. If you have a job, you will learn English and prepare for your three-year plan. Sometimes they run back to see their parents (airplanes).
5, talk about personal development direction of thinking
The recent "Immigration" keyword is hot. Will stay in China for three years, let oneself can independently. will be abroad to develop their own career, on the road of technology to go to the black.
6, say what you think the service-side development engineer should have the ability
Network prerequisites, high concurrency, JVM will be, a variety of distributed technology, the ability to see the source code.
7, say what you think the architect is, what the architect does
Technical Danale, in a number of areas have in-depth research. Coordinating the various technical experts can work well together. Specific areas of the architect function differently, network, underlying, database. At one point can be independently, solve major problems.
8. Talk about the technical experts you understand
A minimum of ten years in a battlefield, and a unique understanding in a particular field. The problem of detail, the problems encountered more than others, solve more problems than others. Suppose to be a Java technical expert, JKD source code, JVM, design pattern (not remember, apply to project). Refactoring for mega projects. The more powerful, the lower the bottom. When one day you don't understand anything, you become a technical expert.
Basic
1. Object-oriented features
Before you tell a feature, you need to know what it is to face, object-oriented OO = object-oriented design Ood + object-oriented analysis Ooa + OOP for object-oriented programming. What other faces? Process-oriented programming, interface-oriented programming, aspect-oriented programming AOP, resource-oriented programming. What is an object? How did the object occur? New class AH (introspective reflection mechanism, container). What does the object define? What is the connection between them? Objects are abstractions of the real world. Objects are generated by the instantiation of a class and describe some of the properties and behaviors of the class. Is it a strong coupling or a virtual coupling? Is it an inheritance or a combination of relationships (IS-A,HAS-A)?

With 1-5 working experience, in the face of the current popular technology do not know where to start, need to break through the technical bottleneck can add group. Stay in the company for a long time, have a very comfortable, but job-hopping interview wall. Need to study in a short period of time, job-hopping to get a high salary can add group. If there is no work experience, but the foundation is very solid, on the Java work mechanism, common design ideas, Common Java Development Framework Master skilled can add group. Java Architecture Group: 5,825,056,431 communication.

Inheritance: Subclasses (derived classes) inherit the parent class (superclass) to perpetuate the parent function, and the subclass itself can be enhanced. All classes inherit from object. Single inheritance limitations, why do all classes inherit object? How to achieve multiple inheritance? Is it good to inherit or combine (aggregate)? Commissioned?

Encapsulation: You may have heard of encapsulating a tool class for me, why encapsulation? Decoupling. How to package? Extraction. Encapsulation method or encapsulation class? How to hide yourself, change without affecting others? 4 keywords, public,private ...

Polymorphism: A thing that shows a different state, people will eat, will run, will jump, will sleep? According to what the brain transmits to it. Does this involve transformation and security? Down? (No,yes). This will lose some of the properties of the object.

With 1-5 working experience, in the face of the current popular technology do not know where to start, need to break through the technical bottleneck can add group. Stay in the company for a long time, have a very comfortable, but job-hopping interview wall. Need to study in a short period of time, job-hopping to get a high salary can add group. If there is no work experience, but the foundation is very solid, on the Java work mechanism, common design ideas, Common Java Development Framework Master skilled can add group. Java Architecture Group: 5,912,408,171 communication.
2, final, finally, finalize the difference

Final: Ultimate, modifier constant, final static. Described in uppercase letters. Static and unchanging. Where do you use global variables? Part of it? Modifiers, subclasses cannot be overwritten (overridden), decorated class (parent class cannot be inherited) The string class is final. Why do you design this? Performance, security, pool.
Finally: Frees resources, IO, threads in try{}catch{}finally{} generally. Regardless of how it always executes? Really, not necessarily. Also need to judge, non-empty, in try once. JDK 8 can be placed directly in the try (...) {}catch{}

Finalize: is a local method that is called by the JVM full GC when scavenging objects that are no longer alive. When does it happen? Two times a time?
3. What is the difference between int and Integer
The former is the basic data type, the post is the reference data type, how to convert between? Can you put it in the collection? JDK 1.5 Auto-boxing, unpacking. Is there a bit of value passing or reference passing?
4. The difference between overloading and rewriting

Used on polymorphic. Methods with the same method name, parameter lists, and different properties. Choose the appropriate method according to the different parameters of the communication. Constructors are also
Rewrite: used in inheritance. The method name is the same as the parameter. The parent class's methods cannot be supplemented when the requirements are met. Do you call the subclass or the parent class when you use it? Super,this. Will this involve the loading process of the class? There is also a static code block.

5. What is the difference between an abstract class and an interface?

Abstract class: The class is called abstract class, when the class is defined, it must be fully implemented when the subclass inherits, if not, it is an abstract class. A bridge between classes and interfaces?
Interface: The standard method is defined by the interface modification, and the method defaults to public abstract modification, and there is no method body. JDK 8 can contain the default method, what is the role? Either all is achieved or not. But the default method comes. Avoids single-inheritance limitations and can implement multiple interfaces

Neither can be instantiated, one to be inherited, and one to be implemented. Which is the best one to use? Depends on the design of your class. interface-oriented programming. Intermediate transition abstract class. Top-level interface projects typically have an abstract class. Down is the implementation class.
6. The use and realization of reflection
What if the world would change without reflection + generics? Dynamically creating objects at run time, with the fully qualified name of the class we can know any information about the class. Fields, methods, construction methods, exceptions, annotations. Almost every frame is almost reflective + generic implementation. There are also dynamic agents. The underlying is implemented using static code blocks. There are four types of implementations: Class. class, Class. GetClass (), Class.forName (), and a class loader implementation, getClassLoader (). (startup, extension, System (APP)). It is important to emphasize the reflection + generics + proxy (jdk,cglib) again.
7. Talking about the scene and implementation of custom annotations
Very, very important, in the framework can help us save a lot of unnecessary code. java specifies that the same annotations cannot appear on a class, so we can customize them.
Public interface Annotation {
Boolean equals (Object obj);
int hashcode ();
String toString (); br/>}
@Retention (Retentionpolicy.runtime)
@Inherited

class<? Extends runner> value ();
}
8. The difference between the GET and POST methods of HTTP requests
Used to submit access forms, resources. The main difference is the address bar, cache, size. Network knowledge must be well understood.

The data address bar of a GET commit usually appears in the form of a key-value pair, connected with "&". The size is also limited (64k?). can be cached.
POSP is used to submit forms and upload images. The data is generally placed in the request body. Size is not limited. cannot be cached.

What about the rest? Put Delete,trance? Here again the testful style.
9. Difference between session and Cookie
The biggest difference is that the location is different, the former is on the service side, the latter is local. But what if the browser restricts cookies? Off-topic: I usually use Click&clean to clear cookies. Some sites will also be disabled. Don't ask me why, in fact, there is no egg, but the cookie holds a lot of important information.

Cookies: Information such as passwords, tokens, etc., are generally stored. Size is limited, at the time of the first request, the server is created, returned to the client, and the second time the browser takes the cookie to find the servers. Is there a cross-domain problem here? You can set expiration to expire. Browser restrictions on cookies. A large number of cookies cause transmission performance. Gzip compression is usually used.
Session, stored on the server side. Generally used in shopping carts also involves cross-domain issues, which can be deposited into redis, and is there a way to replicate each Tomcat instance in reality? Jsession what? What's the effect?

This piece just has to be well mended.
10. Session Distributed Processing
Haha, the preemptive answer. Don't ask for a reply when you are interviewing. Ask the interviewer to choose an answer to your question and go further. Until I asked you not to. You can also say that you have a grasp of the topic, guide him to continue in depth.
11. JDBC Process
Prepare the private static final URL 、、、 can also be read from the file with properties. Load (),
1, first registration drive AH? How to register? Reflection, Class.forName ("Xx.xx.xx.Driver"); how does the bottom layer come true? Static code, Drivermanager.registerdriver? When started, the contents of the static code block are called automatically.
2, Next is to get the connection ah, how to connect? Remote connection (three handshake operation), where is the connection placed? As resources must be placed in the pool. This can improve performance. The common connection pool has dbcp,c3p0, the legendary safest, the best performance Druid (Domestic), but also can monitor.
3, you always have the SQL statement, then the statement compiled that. There is a security issue with SQL injection. Add "1=1" after the statement to set up. So we use a precompiled approach, PreparedStatement. Can prevent this problem from appearing.
4. Get the result set after checking out. Rs.getstring ().
5, the headache has come, release resources. Various if (xx! = nu) {try{xx.close ();} catch{}} Do not worry about JDK8 a new feature that can be placed in the Try-withresource. There are also various anomalies that can be used in the form of channels Xxxexception | Xxxexception
6, a variety of anomalies need you put into a try{}catch{}, problems you do not know where the problem?
Are you in trouble? Don't worry, we can encapsulate it as a tool class and call the tool class when needed. getconnection ();
Still trouble, you can use the Spring framework to provide jdbctemplate,hibernatertemplate for our integration. Eliminate a lot of boilerplate code with template code.
Why didn't you tell me earlier that the JDBC connection was so simple? Comrades, we need to know the same time, but also know the reason why. A better solution can be found when problems arise.
12. MVC Design Idea
What is design thinking? The predecessors stepped on countless pits, summed up the truth. Generally used to solve specific problems. There is a need to learn design patterns, which are used extensively in frameworks.
What's that MVC?
Before we answer, let's look at the principles of design. Single duty, open and close principle, interface-oriented programming, the least known object. In a nutshell: "High cohesion, low coupling." Six characters a comma.

Models (model layer): General storage processing logic,
View Layer: Store html,jsp, file
Controller (Control layer): mainly responsible for scheduling the two, to achieve decoupling.

When we send a request like a browser, we first need to go through the control layer (Dispatcherservlet), which is what it does not actually do and delegate to others to do. Call the model layer (process some business logic), return the data model to the controller, and then parse the view in the delegate view parser. Finally, the resource that is located to the view is returned to the controller, which is returned to the client. (There's actually a lot more to do)
The main purpose is to decouple and perform their duties. Do what you have to do in your job. For extensibility. Increasing the demand does not affect other modules.
13. The difference between equals and = =

= = Compares the addresses, specifically the references that are stored in the stack.
Equsls compares the content. In general, we also need to rewrite the hashcode () method, the bottom of which is "= ="

There are two cases, a comparison of the base type and the reference type. Also involves a constant pool (which improves performance). There are also pooled operations. There are four principles, reflexive, transitive, ...

Gold three silver Four Java interview Clearance Essentials Summary set (Daniel Induction)

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.