Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the middle and advanced interview questions in JAVA?

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "what are the intermediate and advanced interview questions in JAVA". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

What is pessimistic lock, optimistic lock. What's the difference between them? Pessimistic lock: it is believed that there must be competition for resources. Therefore, the resource is locked, and only the visitors who hold the lock can access it, otherwise they need to wait for the release of the resource lock and acquire the lock before they can access the resource. Optimistic lock: concurrent access to resources without conflicts and data inconsistencies. It does not need to be locked, and it is determined that it can be modified only when the version number matches. Difference: pessimistic locks lock resources, poor performance, and deadlocks may occur. How to prevent sql injection? The program filters malicious SQL commands. Escape special characters 2. Do not dynamically splice SQL,PreparedStatement with parameterized assignment 3. What is the transaction propagation behavior of configuring the database permissions of the application https://blog.csdn.net/qq_41685990/article/details/89316575 https://www.cnblogs.com/lansetuerqi/p/12807891.htmlspring? 1. Currently, if there is no transaction, a transaction is created. Propagation_required 2. Currently, if no transaction exists, an exception is thrown. Propagation_mandatory3. Of course, if there is no transaction, the transaction is not used. If it exists, use the current transaction propagation_supports4. If there is a transaction, suspend the current transaction and create a new transaction propagation_required_new 5. 0. Runs as a non-transaction and suspends the current transaction propagation_not_supported 6. 0 if the current transaction exists. Runs as a non-transaction, and throws an exception propagation_never7. If the current transaction exists, create a new nested transaction to run. Currently, if there is no transaction, create a transaction propagation_nested. Assuming that the DB operation of an interface includes writing log and business processing, how to make the log write must be successful. Code logic: write the log first, and then perform the business processing. When performing business processing exception rollback, then logging will not be affected in a new transaction, so logging success https://www.jianshu.com/p/8f576982f574https://blog.csdn.net/wangpeifeng669/article/details/26403119" combination takes precedence over inheritance. Is this description correct? please give your own analysis. Incorrect. Look at the business needs! Specific analysis of the specific situation. The combination is flexible and easy to expand. Otherwise, random combination will lead to overdesign and increase the complexity of the program. Inheritance is suitable for the parent class with few changes, the subclass depends on the properties or methods of the parent class, and the subclass has few attributes or does not need to be extended to use Redis, how to ensure the consistency of the data, please give your own analysis? 1. If concurrency is not high, delete the cache first and then delete the database data. The problem of data inconsistency is greatly reduced compared to deleting database data first and then deleting cache. If you delete the database first, if the deletion of the cache fails, then the data is wrong. two。 In the case of high concurrency: the usual solution is that if we need to use a thread-safe queue to cache updated or deleted data, when the An operation changes the data, a cached data will be deleted first. at this point, the cached data is put into the queue in a thread-safe manner, and the database data is deleted through a thread. When another query request B comes in, if it is found that the value is not in the cache, it will first go to the queue to see if the data is being updated or deleted, and if there is this data in the queue, block and wait until A succeeds in operating the database. Wake up the blocking thread, and then go to the database to query the data. Common algorithms and: algorithm complexity three log functions of https://www.cnblogs.com/zwtgyh/p/10631760.html mysql: https://blog.csdn.net/lhanson/article/details/82752883https://www.jb51.net/article/69676.htmmysql index type: general index, unique index, full-text index (MyISAM support), primary key index Joint indexing method: hash, btree https://blog.csdn.net/weixin_33686714/article/details/91894377mysql execution plan type type: https://www.jianshu.com/p/b5c01bd4a306type access type, indicating the method to find the queried data, the common values of this property are as follows, performance from good to poor: NULL: no need to access a table or index, such as getting the maximum or minimum value of an index column. Eq_ref: when a query is associated with multiple tables, the query is based on a unique non-empty index. Ref: when querying multiple tables, the query is based on a non-unique, non-empty index. Range: do a range lookup on an index. ALL: full table scan, when no indexes are available. This is the worst-case scenario and should be avoided. How does the gateWay gateway of the microservice modify the response content? Redis common data structures, hashmap usage scenarios? What is the namespace of the service registry of the microservice? Hot load update configuration of microservice configuration information? That is, to query out all the organization tree information https://www.cnblogs.com/chywx/p/9420726.htmlhttps://blog.csdn.net/qq_34120430/article/details/849692351, it will be very convenient to maintain all the parent information of the current organization in a field in the middle of the organization table, or to establish a parent-child relationship table or view of the organization! For example, if tree_code stores all its parent ID separated by commas, you can use a federated query to achieve the effect: SELECT sf1.org_name, sf1.tree_code from sso_framework sf1where sf1.id=27UNION SELECT sf2.org_name, sf2.tree_code from sso_framework sf2where sf2.tree_code like'%, 27% Union SELECT sf2.org_name, sf2.tree_code from sso_framework sf2where sf2.tree_code like'27 min% Union SELECT sf2.org_name. Familiar with the basic classes of java such as list, hashmap, etc.: what is kafka? The difference between multithreading and other MQ: multithreaded parameters, for example, how to implement distributed transactions such as MQ, setea, tcc, etc., what are synchronous locks? What is a bias lock and what other locks are there? What are the common notes for spring boot? this is the end of the content of "what are the advanced interview questions in JAVA". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report