Java Technology Stack

Source: Internet
Author: User
Tags cas modifier serialization volatile

Java Technology Stack

1 Java Fundamentals: 1.1 Algorithms
    • 1.1 Sorting algorithms: Direct insert sort, hill sort, bubble sort, quick sort, direct select sort, heap sort, merge sort, base sort
    • 1.2 Two-fork search tree, red-black tree, B-tree, + + tree, LSM tree (corresponding applications, database, HBase, respectively)
    • 1.3 Bitset solve problems such as data duplication and presence
1.2 Basic
  • 2.1 Migration of string constant pools
  • 2.2 String KMP algorithm
  • 2.3 Equals and Hashcode
    • 1. The Equals method is used to compare the contents of an object for equality (overwrite later)

      2. The Hashcode method is used only in the collection

      3. When the Equals method is overridden, the comparison objects are compared by the overridden Equals method (judging whether the object's contents are equal).

      4. When putting an object into a collection, first determine whether the Hashcode value to be placed on the object is equal to the hashcode value of any of the elements in the collection, and if not equal, put the object directly into the collection. If the hashcode value is equal, then the Equals method is used to determine if any of the objects in the collection are equal, and if equals does not determine equality, the element is placed directly into the collection, otherwise it is not put.

      5, the flow of elements into the collection:

  • 2.4 Generics, exceptions, reflections
  • hash algorithm of 2.5 string
    • Designing efficient algorithms often requires the use of hash tables, and the O (1)-level lookup speed is unmatched by any other algorithm.
      The so-called hash, is generally an integer, through an algorithm, you can put a string "pack" into an integer, this number is called a hash, of course, an integer cannot correspond to a string.
      So the hash function is the core part of the hash table, for a hash function, the criteria for evaluating its merits should be random or discrete, that is, any set of specimens, into the hash table each cell (cells) of the probability of the average degree, because the probability of the more average, Two string calculated hash value equal hash collision the smaller the likelihood, the more evenly the data is distributed in the table, the higher the space utilization of the table.
  • 2.6 Hash Conflict Resolution: Zipper method
    •   

      Zipper method
      (1) method of resolving conflicts by zipper method
      Zipper method The conflict resolution approach is to link all keywords as synonyms to the same single linked list. If the hash list length selected is M, the hash list can be defined as an array of pointers consisting of M head pointers T[0..m-1]. All nodes with hash address I are inserted into a single linked list with T[i] as the head pointer. The initial value of each component in T should be a null pointer. In the Zipper method, the filling factor α can be greater than 1, but generally take α≤1.
      "Example" with M = 5, H (k) = K mod 5, key value Order Example 5, 21, 17, 9, 15, 36, 41, 24, hash table established by the outer chain address method as shown:


                
      (2) Advantages of the Zipper method
      compared with open addressing method, the Zipper method has the following advantages:
      ① zipper method to deal with the conflict is simple, and no accumulation phenomenon, that is, non-synonym will never conflict, so the average search length is shorter;
      ③ open addressing method to reduce the conflict, the loading factor α is required to be small, so when the node size is larger, it will waste a lot of space. While the Zipper method is preferable to α≥1, and the node is larger, the increase of the pointer field in the Zipper method is negligible, thus saving space;
      ④ in a hash list constructed with the Zipper method, the operation of deleting nodes is easy to implement. Simply delete the corresponding node on the list. In the case of a hash table constructed by the open address method, the deletion node cannot simply empty the space of the deleted node, otherwise it will truncate the lookup path of the synonym node of the hash table after it. This is because in various open address laws, empty address units (that is, open addresses) are the criteria for finding failures. Therefore, the delete operation is performed on the hash list that handles the conflict with the open address method, and the deletion mark can only be done on the deleted node, instead of the node being actually deleted.

      (3) Disadvantages of zipper method
         The disadvantage of the   zipper method is that the pointer needs extra space, so when the node size is small, the open addressing method is more space-saving, and if the saved pointer space is used to enlarge the scale of the hash table, the filling factor will be reduced, which reduces the conflict in open addressing method, thus improving the average search speed.

  • 2.7 The principle of the Foreach Loop
    •   
      • For the list compiler to invoke the iterator method of the Iterable interface to iterate through the elements of the array, the iterator method is to invoke the next () and Hasnext () methods of the iterator interface to do the loop traversal. There is a design pattern in Java called an iterator pattern , which is actually an implementation of the iterator pattern .
      • For arrays, it is a circular reference that translates to each element in an array
  • 2.8 The role of static, final, transient and other keywords
    •   

      Static and final

      Static modifier keywords, can modify variables, program block, class method;

      When you define a static variable, the JVM allocates it to the memory heap, and all references to it will point to that address without reallocating the memory;

      When modifying a program block (that is, writing the code directly in the static{...} , the virtual machine loads the code in the static block first, which is used primarily for system initialization;
      When you modify a class method, you can call it directly from the class without needing to create a new object.

      Final can only be assigned one time, modifying variables, methods, and classes,
      When you define a final variable, the JVM assigns it to a constant pool, and the program cannot change its value; When you define a method, the method cannot be overridden in a subclass, and when you decorate a class, the class cannot be inherited.

      Static and final use scopes: classes, methods, variables.

      2. Distinction and Contact:

      2.1.static meaning: Static, statically decorated methods and properties belong to any object that the class does not belong to the class.
      2.2.static usage:
      2.2.1.static can decorate "inner classes", methods, and member variables.
      2.2.2.static "Cannot decorate the outer class", "cannot decorate the local variable" (because static is defined as the class level, so the local level variable is not static decorated).

      2.3 Final Meaning: "Can only be assigned once".
      2.2.final usage:
      A 2.2.1.final decorated property that indicates that the property can only be assigned once, (1) The base type: The value cannot be modified, and (2) the reference type: The reference cannot be modified.
      The 2.2.2.final decoration method, which indicates that the method cannot be overridden, but can be accessed by a quilt class if the method is not private type.
      A 2.2.2.final decorated class that indicates that a class cannot be inherited.

      3. Combined use of static final

      3.1. Scope of application:

      3.1.2. The intersection of the two ranges, so it can only be modified: member variables, methods, inner classes.

      3.2. Meaning: Also the intersection of the two:
      3.2.1. Method: A method that belongs to a class and cannot be overridden.
      3.2.2. Member variable: A variable that belongs to a class and can be assigned only once.
      3.2.3. Inner class: Belongs to an external class and cannot be inherited


      Type modifiers, which can only be used to decorate a field, if an instance variable is declared with transient, its value does not need to be maintained when the object is stored. In other words, a member variable tagged with the transient keyword does not participate in the serialization process.

  • The underlying implementation principle of the 2.9 volatile keyword
    •   

      Volatile
      Volatile is also a variable modifier and can only be used to modify variables. A volatile-modified member variable forces the value of the member variable to be reread from shared memory each time it is accessed by the thread. Also, when a member variable changes, forcing the thread to write the change back to the shared memory. So at any moment, two different threads always see the same value for a member variable.

      Explain Java's memory mechanism here:

      Java uses one main memory to hold the current value of the variable, and each thread has its own working memory. When a thread accesses a variable, it copies the value of the variable into its own working memory, so that when the thread operates on a variable in its own working memory, the value of the variable copied in the working memory is different from the value of the variable in the main memory.

      The Java language specification states that for optimal speed, a thread is allowed to save a private copy of a shared member variable, and is compared to the original value of a shared member variable only if the thread enters or leaves the synchronized code block.

      This way, when multiple threads interact with an object at the same time, it is important to notice that the thread gets the changes to the shared member variables in a timely manner.

      The volatile keyword is a hint to the VM: You cannot save its private copy for this member variable, but you should interact directly with the shared member variable.

      Usage Recommendation: Use volatile on member variables accessed by two or more threads. You do not have to use the variable you want to access when it is already in a synchronized code block, or is a constant.

      It is inefficient to use volatile to mask the necessary code optimizations in the VM, so use this keyword when necessary.

  • What sort method is used by the 2.10 Collections.sort method
    •   

      Collections is a tool class that serves collection (static), which defines the methods that a collection can use.

      This article demonstrates the two methods of sort () in the collections class. The first is to simply pass in the sorted collection and sort it naturally. But sometimes we need to customize the way we sort, which is that we have to define a comparator that defines the way we want to sort, and when we call sort (), the sorted set and the comparer are passed in at the same time, and can be sorted in a custom way.

  • 2.11 Future interface, futuretask implementation in common thread pooling, etc.
  • Internal details of the intern method of the 2.12 string, changes in jdk1.6 and jdk1.7, and implementation of the internal CPP code stringtable
1.3 Design Patterns
    • Single-Case mode
    • Factory mode
    • Decorator mode
    • Viewer design Pattern
    • Threadlocal design mode
    • 。。。
1.4 Regular Expressions
    • 4.1 Capturing and non-capturing groups
      • http://www.360doc.com/content/12/0123/05/820209_181153675.shtml
    •     
    • 4.2 greedy, barely, exclusive mode
      • Matches three quantifiers in regular expressions: greedy (greedy), grudging (reluctant), exclusive (possessive)

        Greedy non-greedy (?)      Exclusive (+)
        x?       X??       X?+
        x* x*?        X*+
        x+ x+?         X++
        x{n}  x{n}?         X{N}+
        x{n,}     X{n,}?        x{n,}+
        x{n,m} x{n,m}?  x{n,m}+

        Greedy: greedy
        matches the longest. In greedy quantifier mode, the regular expression matches the strings that match the rules as long as possible and backtracking.

        Reluctant: non-greedy
        matches the shortest. In non-greedy quantifier mode, the regular expression matches the string as short as possible.

        possessive: Exclusive

1.5 Java memory model and garbage collection algorithm
    • 5.1-class loading mechanism, that is, parental delegation model

      • See JVM P229
    • 5.2 Java Memory allocation model (default hotspot)

      Threads shared: Heap zone, Permanent zone thread exclusive: virtual machine stack, local method stack, program counter

    • 5.3 Memory allocation mechanism: Young Generation (Eden area, two survivor area), old generation, permanent generation and their distribution process

    • 5.4 Strong references, soft references, weak references, virtual references, and GC

    • 5.5 Happens-before Rules

    • 5.6 Order reordering, Memory fence

    • 5.7 Memory generational improvements for Java 8

    • 5.8 Garbage Collection algorithm:

      Mark-Clear (Deficiency: inefficient, memory fragmentation)

      The replication algorithm (which solves the above problem, but only half of the memory, for most of the object survival time of the scene, led to a default 8:1:1 improvement, the disadvantage is still need to use the outside to solve the problem may not be able to load)

      Tag Grooming

    • 5.8 Common garbage Collectors:

      Cenozoic: Serial collector, parnew Collector, Parallel scavenge collector

      Older years: Serial old collector, Parallel old collector, CMS (Concurrent Mark Sweep) collector, G1 collector (spanning Cenozoic and older years)

    • 5.9 Parameters for common GC:-XMN,-XMS,-xmx,-xx:maxpermsize,-xx:survivorratio,-xx:-P rintgcdetails

    • 5.10 Common tools: JPS, Jstat, Jmap, Jstack, graphical tools jconsole, Visual VMS, MAT

1.6 Locks and the source code of concurrent containers
    • 6.1 Synchronized and volatile understanding
    • 6.2 The principle of unsafe class, use it to implement CAs. So the birth of Atomicinteger series, etc.
    • 6.3 CAs may be the solution of ABA problems, such as the number of changes to add, version number
    • The implementation principle of the 6.4 Synchronizer Aqs
    • 6.5 exclusive lock, shared lock, reentrant exclusive lock Reentrantlock, shared lock implementation principle
    • 6.6 Fair lock and non-fair lock
    • 6.7 The realization principle of the read-write lock Reentrantreadwritelock
    • 6.8 Locksupport Tools
    • 6.9 condition interface and its implementation principle
    • 6.10 HashMap, HashSet, ArrayList, LinkedList, HashTable, concurrenthashmap, treemap implementation principle
    • Concurrency Problems of 6.11 HashMap
    • The realization principle of 6.12 Concurrentlinkedqueue
    • 6.13 Fork/join Frame
    • 6.14 Countdownlatch and Cyclicbarrier
1.7-Wire Cheng code
    • 7.1 Internal Execution principle
    • 7.2 Differences in various thread pools
2 Web aspect: Architecture design of 2.1 SPRINGMVC
    • 1.1 Servlet Development problems: Mapping problem, parameter acquisition problem, format conversion problem, return value processing problem, view rendering problem
    • 1.2 Springmvc Several major components and interfaces developed to address these issues: handlermapping, Handleradapter, Handlermethodargumentresolver, Httpmessageconverter , Converter, Genericconverter, Handlermethodreturnvaluehandler, Viewresolver, Multipartresolver
    • 1.3 The relationship between Dispatcherservlet, container and component
    • 1.4 Description of the SPRINGMVC process for the overall request
    • 1.5 Springboot
2.2 SPRINGAOP Source
    • 2.1 AOP Implementation Classification: Compile time, byte code before loading, three time after bytecode loading to implement AOP

    • 2.2 Deep understanding of the roles: AOP Federation, ASPECTJ, JBoss AOP, Spring Self-implemented AOP, spring embedded ASPECTJ. Especially if you can differentiate between the two by code

    • 2.3 Interface Design:

      Concepts or interfaces defined by the AOP Alliance: Pointcut (concept, no corresponding interface defined), Joinpoint, Advice, Methodinterceptor, methodinvocation

      SPRINGAOP interfaces and their implementation classes defined for the advice interface described above: Beforeadvice, Afteradvice, Methodbeforeadvice, Afterreturningadvice Aspectjmethodbeforeadvice, Aspectjafterreturningadvice, Aspectjafterthrowingadvice, ASPECTJ for the above interface Aspectjafteradvice.

      SPRINGAOP defined Advisoradapter interface: Convert the above advise to Methodinterceptor

      SPRINGAOP defined Pointcut interface: contains two properties Classfilter (Filter Class), Methodmatcher (filtering method)

      Expressionpointcut interface defined by SPRINGAOP: pointcut expression that introduces ASPECTJ in implementation

      SPRINGAOP defined Pointcutadvisor interface (combining the above advice interface and Pointcut interface)

    • 2.4 Springaop Call Flow

    • 2.5 SPRINGAOP their own implementation (representing the character Proxyfactorybean) and the ASPECTJ implementation of the way to differentiate

2.3 Spring Transaction system source code and distributed transaction JOTM Atomikos source code implementation
    • 3.1 Problems with JDBC transactions
    • 3.2 Hibernate improvements to the transaction
    • 3.3 For a wide variety of transactions, spring defines the interface of the transaction architecture and how the JDBC transaction and hibernate transactions are fused
    • 3.4 Three types of transaction models contain roles and their respective responsibilities
    • 3.5 Transaction Code also implementation of business code separation (aop+threadlocal)
    • 3.6 Spring Transaction Interceptor Transactioninterceptor Panorama
    • 3.7 X/open DTP model, two-phase commit, JTA interface definition
    • The realization principle of 3.8 jotm and Atomikos
    • 3.9 propagation properties of a transaction
    • 3.10 Propagation_requires_new, propagation_nested the principle of realization and difference
    • 3.11 Principles of the hang and restore of things
2.4 Database Isolation Level
    • 4.1 READ UNCOMMITTED: not submitted
    • 4.2 Read Committed: Read Committed
    • 4.3 repeatable read: Repeatable READ
    • 4.4 Serializable: Serialization
2.5 database
  • 5.1 Optimization of database performance

  • 5.2 Deep understanding of MySQL's record Locks, Gap Locks, Next-key Locks

    For example, under what circumstances the deadlock will occur:

    Start transaction; DELETE from t WHERE id = 6; INSERT into T VALUES (6); Commit

  • 5.3 Lock of INSERT INTO SELECT statement

  • 5.4 The acid characteristic concept of the transaction

  • 5.5 InnoDB's MVCC understanding

  • 5.6 Undo Redo Binlog

    • 1 undo redo can be persisted, what is their process? Why choose Redo to do persistence?
    • 2 undo, Redo combine to achieve atomicity and persistence, why is undo log persisted prior to redo log?
    • 3 Why should undo rely on redo?
    • 4th log content can be a physical or logical log? What are their respective strengths and weaknesses?
    • 5 Redo Log is finally used for physical log plus logical log, physical to page,page internal logic. What's the problem? How to solve? Double Write
    • 6 Undo Log Why not use the physical log and the logical log?
    • 7 Why should I introduce checkpoint?
    • 8 after introducing checkpoint to ensure consistency needs to block user operation for a period of time, how to solve this problem? (The problem is still pervasive, and Redis, zookeeper have similar scenarios and different coping strategies), with synchronous checkpoint and asynchronous checkpoint
    • 9 General process of internal 2PC of transactions (with 2 persistence, redo log and binlog persistence) when Binlog is turned on
    • 10 Explain the above procedure, why is Binlog persisted after redo log, before the storage engine commit?
    • 11 Why should I maintain the order of write Binlog and execute storage engine commit operations between transactions? (That is, the transaction written to the Binlog log must first commit)
    • 12 in order to ensure the above order, the previous approach is locking Prepare_commit_mutex, but this greatly reduces the efficiency of the transaction, how to implement the Binlog group commit?
    • 13 How do I implement a group commit for the persistence of redo log? The process of 2PC within the transaction, 2 persisted operations can be group commit, greatly improve the efficiency
2.6 ORM Framework: MyBatis, Hibernate
    • 6.1 The most primitive jdbc->spring of the JDBCTEMPLATE->HIBERNATE->JPA->SPRINGDATAJPA evolution of the road

Java Technology Stack

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.