Java face Test List __java for frontline internet companies

Source: Internet
Author: User
Tags exception handling rand rollback try catch
Java face test list for first-line internet companyJava Key knowledge

Multithreading (thread state, thread concurrency, synchronized and lock differences and underlying principles, commonly used locks and their use of scenes and principles,

Volatile and threadlocal solve the problem, the implementation of CAs in Java

Thread pooling principles and implementations, blocking queues and thread-safe queues,

Inter-thread communication: Synchronized + wait, Notify/notifyall, Lock + Condition multiplexing,

Role and usage of Countdownlatch, cyclicbarrier and semaphore, use of scenes)


JVM memory management mechanism and garbage collection mechanism (memory model, GC policy, algorithm, generational recovery GC type, full GC, Minor GC scope and trigger condition)


JVM Memory Tuning (6 parameters for memory tuning, understand what's going on, generally do more in the project process)


Design pattern (familiar with common design patterns of the application scene, will draw class diagram, commonly used: agent, 2 factories, strategies, single, observer, adapter, combination and decoration)


Java Collection Class Framework (understanding the relationships and differences between frames, HASHMAP, ArrayList, HashSet, and so on, where the HASHMAP storage mechanism is almost always asked)


HashMap principle, underlying data structure, rehash process, pointer collision problem HASHMAP thread safety problem, why would produce such thread safety problems CONCURRENTHASHMAP data structures, underlying principles, put and get whether thread safe

Java Exception handling mechanisms (classification of exceptions, common exceptions, Try catch finally used)


JVM running mechanism (understanding how the JVM works, understanding class loading mechanisms and initialization order of classes)


Java NiO 3 main Concepts Channel, Buffer, and Selector, why improve performance. Add sub-item: familiar with the Netty


Linux Basics (There are some requirements for Linux in the interview written test, it is advisable to build a Linux virtual machine, and practice the commonly used commands)
Framework SpringSpring IOC principle, bean generation and Lifecycle (Factory mode + reflection Generation + single case), Spring used design pattern

Spring AOP Principles and applications (dynamic proxies and cglib proxies, using scenarios and proxies for essential differences)

How spring handles high concurrency. High concurrency, how to ensure performance.
Single case mode + ThreadLocal
Single case mode greatly saves the creation and destruction of objects, improves performance, threadlocal is used to ensure thread security
In spring Singleton mode, the threadlocal is used to toggle the direct parameters of different threads, and threadlocal is used to ensure thread safety, in fact, threadlocal key is the thread instance of current threads
In singleton mode, spring puts the parameter values of a thread-safety problem for each thread into the threadlocal, although it is an instance, but the data under different threads is isolated from each other.
Because the run-time creation and destruction of beans is greatly reduced, in most scenarios, this approach consumes less memory resources, and the higher the concurrency, the more obvious the advantages
Special Note: The Controller of Spring MVC is not thread-safe ... Spring MVC is a method based interception, with finer granularity, and spring's controller default is singleton, that is, each request requests that the system will be processed with the same controller.
Spring MVC and Servlet are method-level thread-safe, and if instance variables exist in the controller or servlet of a single example, they are thread insecure, and Struts2 is indeed thread-safe
Advantages:
Reduces object creation and destruction without creating controller every time
Disadvantages:
Controller is a single case, the variable thread inside the controller is unsafe
Solution:
1. Use the threadlocal variable in controller to encapsulate unsafe variables into threadlocal, use threadlocal to save class variables, save class variables in the variable field of the thread, and separate requests
2. Declare controller as prototype Scope= "prototype", each request creates a new controller
No instance variables used in 3.Controller

The use and rationale of Spring transaction management. Propagation properties of a transaction
Declarative transaction management, on top of service or service method, add @Transactional annotation
how @Transactional work.
When spring starts, it resolves the generated bean, which looks at the classes and methods that have the relevant annotations.
The agents are generated for these classes and methods, and the related configuration is injected according to the relevant parameters of the @Transactional.
This will dispose of the related transaction in the proxy (turn on the normal commit transaction, the exception rollback TRANSACTION)
Real database layer, transaction commit and rollback are implemented through Binlog and redo log


How spring resolves an object's circular dependency reference. (only support for singleton scoped, setter-mode loop dependencies ...) , constructor mode and prototype loop dependencies are not supported)
Principle:
When you create a bean a, an instance of a is created first through the parameterless constructor, when the property is empty, but the object reference is created, and then the reference to bean A is exposed ahead of time.
Then, when the B property is setter, a B object is created, and a reference to a B object is constructed with the parameterless constructor, exposing the B object reference.
Then B executes the setter method, finds a in the pool (because at this point, a has been exposed, has a reference to the object), which relies on B to construct it, initialize it, and then initialize it to complete,
Recycling depends on the solution ...

Summarize:
First create the object reference, and then through the setter () method, assign values to the property, layer to create the object ...


When Bean a initializes, its dependent B is initialized, and the default parameterless constructor is used to generate its own reference without invoking its setter () method.
When a B object is created, if it is also dependent on C, a reference to B is generated through the parameterless constructor,
When C object is created, if A is referenced, a reference to a is found in the object pool, then a setter () is called, and a is injected into a to complete the creation of the C object.
After C is created, B uses the setter () method to inject C, complete the B object creation,
After the B object scene is finished, a uses the setter () method, injecting B, completes a object creation,
Finally, the loop dependency of the setter () method is completed.
DatabaseInnoDB and MyISAM differences and selection 1.InnoDB does not support indexes of fulltext types.
The number of rows in the table is not saved in 2.InnoDB, that is, when the select count (*) from table is executed, InnoDB scans the entire table to calculate the number of rows, but MyISAM simply reads out the saved rows. Note that when the COUNT (*) statement contains the Where condition, the operations of the two tables are the same.
3. For Auto_increment type fields, the InnoDB must contain only the index of the field, but in the MyISAM table, you can establish a federated index with the other fields.
4.DELETE from table, InnoDB does not re-establish the table, but deletes one row at a time.
5.LOAD table from Master does not work for InnoDB, the solution is to first change the InnoDB table to MyISAM table, import the data and then change to InnoDB table, but for the use of additional InnoDB features (such as foreign key) of the table does not apply.


In addition, row locks on innodb tables are not absolute, and if MySQL cannot determine the range to scan when executing an SQL statement, the InnoDB table also locks the entire table, such as Update table set num=1 where name like "%aaa%"
Any kind of table is not omnipotent, only appropriate for the business type to choose the appropriate table type, in order to maximize the performance of MySQL advantage.

Pessimistic lock and optimistic lock meaning (pessimistic lock: True lock, only allow one thread to manipulate the same record, optimistic Lock: a conflict detection mechanism, generally by version number or timestamp mode, the performance impact is small)
Index usage and its indexing principle (index bottom implementation: B + Tree)
Query optimization
1.explain SQL view execution efficiency, positioning optimization object performance bottlenecks
2. Always drive large result sets with small results
3. Finish sorting as much as possible in the index
4. Take out only the column you need instead of *
5. Use the most effective filtration conditions
6. Use table joins instead of subqueries
7. Use limit 1 when only one row of data is used
8. Indexing the search fields
9. Never order by RAND (), avoid select *
10. Use not NULL whenever possible
11. Open query cache and optimize query statement for query caching
eg
Select username from user where add_time >= now ()
Attention:
1. Such statements do not use query caching,
2. Such SQL functions as now () and rand () or otherwise do not open the query cache because the return of these functions is variable. So all you need is to use a variable instead of the MySQL function to open the cache
3. Modify, the now () processing, only take the month and YYYY-MM-DD, into a change of value
5 data structure of redis and persistence mechanism of using scene Redis
2 implementations of the bottom of the hash type in Redis (compressed table: Save memory and Jump table: query faster) Redis as distributed Message Queuing, performance and attention points



data structures and algorithms

The common sorting algorithm does not say, need to understand its principles and write code, and time space complexity also need to know

Queues, stacks: need to understand their access structure and can be used in some scenarios

Binary tree: Tree traversal, tree depth, hierarchical output, balanced binary tree, reverse print tree, etc.

Linked list: Reverse order, merge two orderly linked list, determine whether the linked list is also ring, the chain list of the reciprocal k elements, etc.

String: KMP algorithm, dynamic programming (this is the focus, need to understand the dynamic programming, common problems are: the longest palindrome string, solve the longest common substring, etc.)

Mass data processing: Now a lot of big companies will ask a large number of processing, so need to master common processing methods, such as Bit-map, divide and conquer, hash map, etc., you can see the relevant articles Baidu, deepen understanding

Common Algorithms

Bubble sort

Quick Sort

Insert Sort

Hill sort

Merge sort

Heap Sort

Bucket sort

Dynamic programming

Longest common substring

The longest palindrome string

Maximum k value of array

The sum of the maximum contiguous array of numbers

Related Article

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.