Java R&D Engineer Interview Questions

1. What is the difference between String, StringBuffer and StringBuilder? Why is String immutable?
1. String is a string constant, StringBuffer and StringBuilder are string variables. StringBuffer is thread-safe, StringBuilder is not thread-safe. Specifically, String is an immutable object. Every time you modify the String object, you actually create a new object and point the reference to the new object. low efficiency. StringBuffer

It is variable, that is, each modification is only for itself. In most cases, it is more efficient than String. StringBuffer guarantees synchronization (synchronized), so it is thread safe. StringBuilder does not implement synchronization, so it is not thread-safe. But the efficiency should be higher than StringBuffer. It is better to specify the capacity when using StringBuffer, which will be 30%-40% faster than the unspecified capacity, and even faster than the StringBuilder without the specified capacity.
2. What is the difference between VECTOR, ARRAYLIST and LINKEDLIST?
Vector is synchronized, arraylist and linkedlist are not synchronized. At the bottom level, both vector and arraylist are implemented based on object[]array, but the thread safety of vector is considered, so the efficiency of arraylist is faster than vector last time. In terms of random access to elements, vector and arraylist are basically the same, the time complexity is O(1), and the complexity of random access elements of linkedlist is O(n). But in inserting and deleting data, linkedlist is much faster than arraylist. Linkedlist occupies more memory than arraylist, because each node of linkedlist also stores references to the two nodes before and after.
Third, the difference between HASHTABLE, HASHMAP, TreeMap
Hashmap and HashTable both implement the Map interface, but HashTable is thread-safe, HashMap is not thread-safe. HashMap allows the key-value value to be null, but HashTable does not allow it. HashMap is suitable for single thread, HashTable is suitable for multithread. The default size of the hash number in HashTAble is 11, and the increase method is old*2+1. The default size of the hash in HashMap is 16, and both are exponents of 2. TreeMap can arrange the retained data according to the key value, according to the specified sorting method. The default is ascending.

Fourth, the difference between ConcurrentHashMap and HashTable
Both are used in multithreading, but when the HashTable increases to a certain extent, its performance will drop sharply. Because it will be locked for a long time during iteration. But ConcurrentHashMap introduces segmentation to ensure that the number of locks will not be large. In short, HashTable will lock the real map, while ConcurrentHashMap only needs to lock one part of the map.
Five, the difference between Tomcat, apache, jboss
Tomcat is a servlet container for parsing jsp and servlet. It is a lightweight and efficient container; the disadvantage is that it does not support EJB and can only be used for Java applications.

Apache is an http server (web server), similar to IIS, which can be used to build virtual sites and compile and process static pages. Support SSL technology, support multiple virtual hosts and other functions.

Jboss is an application server. The javaee application server running EJB follows the javaee specification and can provide more platform support and more integrated functions, such as database connection, JCA, etc. Its support for servlet is achieved by integrating other servlet containers. Such as tomcat.
Sixth, the difference between GET and POST
get is to obtain data from the server, and post is to send data to the server.

Get is to add the parameter data queue to the URL pointed to by the action attribute of the submitted form, and the value corresponds to each field in the form one-to-one, which can be seen in the URL. Post is through the HTTPpost mechanism, each field in the form and its content are placed in the html header and sent to the URL address pointed by the action attribute.

For the get method, the server side uses request.QueryString to obtain the variable value, and for the post method, the server side uses request.Form to obtain the submitted data. The amount of data transmitted by get is small, and the post is large, so it is generally not restricted. The security of get is lower than that of post, but the execution efficiency is higher.

Seven, SESSION, COOKIE distinguishes the
session data on the server, and the cookie on the client's browser. Cookies are not very secure, because local cookies can be analyzed and cookie spoofing can be performed. If you consider security, you should use session. The session will be stored on the server for a certain period of time. When the number of visits increases, it will take up the performance of the server. Cookies should be used to reduce server pressure. The data held by a single cookie does not exceed 4k, and many browsers limit the storage of a maximum of 20 cookies for the site.
8. The life cycle of a Servlet is
mainly divided into three stages: initialization-calling the init () method, responding to customer requests-calling the service () method, termination stage-calling the destroy method. How it works: The customer sends a request, and the servlet calls the service method to respond to the request, that is, matches the request method, chooses to call the doGet, doPost methods, etc., and then enters the method to call the logic layer method to achieve the response to the customer. Custom servlet must first servlet interface.

The specific life cycle includes: loading Servlet, server creating Servlet instance, server calling Servlet's init() method, client request arriving at server, server creating request object, service creating corresponding object, server activating service method of Servlet, request object and response object as The parameters of the service() method, the service() method obtains information about the requested object, processes the request, accesses other resources, and obtains the required information. The service() method may activate other methods to process the request, such as doGet(), doPost()
Nine, HTTP message contains content

Request methods include GET, POST, HEAD, PUT, TRACE, OPTIONS, and DELETE. Request headers such as: Host, User-Agent, Connection, Accept-Charset, etc. There will be a blank line at the end of the request header, indicating the end of the request header, followed by the request body. This line is very important and indispensable. The request body is an optional part, such as get not.
10. The difference between Statement and PreparedStatement, what is SQL injection, and how to prevent SQL injection
Using PreparedStatement can improve the readability and maintainability of the code, and improve performance as much as possible. Because Statement is compiled every time a SQL command is executed, but PreparedStatement is compiled only once. PreparedStatement is similar to pipeline production. On the other hand, PreparedStatement can greatly improve security: it enforces parameter type conversion on the passed parameters to ensure that when inserting or querying data, it matches the underlying database format.

SQL injection: It is to deceive the server to execute malicious SQL commands by inserting the sql command into the web form submission or entering the query string of the domain name or page request. Such as the sql command: select id from test where name='1' or 1=1; drop table test, but this problem can be avoided by using PreparedStatement.
11. The difference between redirect and forward
redirect: The server sends a status code according to logic to tell the browser to request that address again. So the address bar shows the new url. Forward refers to the server requesting resources, directly accessing the target address url, reading the response content and sending it to the browser. The browser does not know where the resource comes from, so the address bar remains unchanged.

Redirect cannot share data, forward forwarding the page and forwarding to the page can contribute the data in the request. Redirect is used to log out, and forward is used to log in. Forward efficiency is higher than redirect.

12. Regarding the JAVA memory model, an object (two attributes, four methods) is instantiated 100 times, the current storage state in the memory, several objects, several attributes, and several methods.
Java's new objects are all placed in the heap. If instantiated 100 times, 100 objects will be generated in the heap. Generally, the object and its properties and methods belong to a whole, but if the properties and methods are static, the properties and methods are only in memory. Save a copy.
Thirteen, talk about the understanding of Hibernate, the role of the primary and secondary caches, how Hibernate uses the cache in the project The
primary cache is the basic cache of the session, which is built-in and cannot be uninstalled. When a Session performs a query operation, it will put the result in the first-level cache. If the same operation is performed by the session in a short period of time, then hibernate will directly obtain the data from the first-level cache.

The second level cache is the cache of SessionFactory, which is divided into two types: built-in cache and external cache. That is, the query result is placed in the second-level cache. If a session created by the same sessionFactory performs the same operation, hibernate will get the result from the second-level cache. The data suitable to be placed in the secondary cache includes: data that is rarely modified, data that is not very important, data that is allowed to occur occasionally, data that will not be accessed concurrently, and reference data. Data that is not suitable to be placed in the secondary cache: data that is frequently modified, financial data, and data that is absolutely not allowed to be concurrent, and shared with other applications.
14. Reflection, let’s talk about it. It is mainly about concepts, where reflection mechanisms are needed, the performance of reflection, and how to optimize
programs that can analyze the capabilities of the program called reflection. The reflection mechanism can be used: the ability to analyze the class during operation, and view the object during operation, such as writing a toString method for all classes to use. Realize universal data manipulation code. Using the Method object, this object is much like a C++ pointer.

The reflection performance optimization method is mainly to set the safety check.

15. Talk about the difference between Hibernate and Ibatis. Which performance will be higher. Some
Ibatis is relatively simple and easy to use. Hibernate is more complicated and has a higher threshold. If the system needs to process a large amount of data and has high performance requirements, and it needs to execute highly optimized SQL statements to meet the performance requirements, then Ibatis will be better at this time.

Hibernate is better for different databases, because Ibatis needs to modify more fields. In addition, Hibernate has become the mainstream o/r Mapping framework, with high development efficiency.
16. What do you use in the project for your understanding of Spring? How to use it? Understanding and implementation principles of IOC and AOP

17. Thread synchronization and how to control concurrent operations.
Thread synchronization is not necessarily at the same time, but coordinated steps, or coordinated synchronization. Thread synchronization means that multiple threads have a causal relationship with each other logically, so the order of execution must be coordinated.

Thread concurrency refers to the simultaneous execution of multiple threads in the same time interval. If the threads can be distinguished in time, then the thread can sleep for the specified time for synchronization, which can be done with the sleep() method. If threads cannot be distinguished in time, but can be distinguished in logical order, then the jion() method can be used to complete, one is executed first, and then the other is executed. If the thread design is more complicated, then only through wait (), notify () method to complete

18. Describe the working process of struts.

The simple process is to start the web application, receive user requests and match, and return user request information.
1. When the web application starts, the ActionServlet is loaded and initialized. The ActionServlet reads the configuration information from the struct-config.xml file and stores them in each configuration object.

2. When ActionServlet receives a client request, it first retrieves the ActionMapping instance that matches the user request, and if it does not exist, returns the invalid information of the user request path.

3. If the ActionForm instance does not exist, create an ActionForm object and save the form data submitted by the customer in the ActionForm object.

4. Determine whether form validation is required according to the configuration information. If validation is required, call the Validate() method of ActionForm. If the Valiedate() method returns null or returns an ActionErrors object that does not contain an ActionMessage, it means that the form validation is successful.

5. ActionServlet decides which Action the request should be forwarded to based on the mapping information contained in the ActionMapping instance. If the corresponding Action instance does not exist, create this instance first, and then call the execute() method of the Action.

6. The execute() method of Action returns an ActionForward object, and ActionServlet forwards the client request to the JSP component pointed to by the ActionForward object.

7. The dynamic web page generated by the jsp component pointed to by the ActionForward object is returned to the customer.

19. Tomcat session processing, if you want to implement a tomcatserver, how to implement the session mechanism.
When a session starts, the Servlet container creates an HttpSession object, and in some cases transfers these HttpSession objects from memory to the file system Or in the database. Load them into memory when they need to be accessed. The advantage of this is to save memory. When the web server fails, the session data can be restored from the file system or database. There are two classes of session management: 1) StandardManager, which is a default class, will save the session object to the specified file when tomcat is started or reloaded. 2) PersistentManager, the management method is more flexible, with fault tolerance, it can back up the Session to the Session Store in time, and can control the number of Sessions in the memory.
Twenty. About Cache (Ehcache, Memcached)
Memcache: Distributed memory object caching system, which occupies the memory of other machines. In many Internets, three load balancing (take three as an example) web servers can share the resources of one Memcache. The information passed is stored in the form of key-value pairs. The transmitted data must be serialized.

Oscache: Page-level cache (the most emphasized thing on the Internet), which occupies the memory resources of the machine. You can choose to cache to the hard disk. If you access the hard disk and restart the service, you can also retrieve the last persistent resources, but if you cache to the memory, it won’t work. Generally, there is no need to cache to the hard disk, because I/O operations are also resource-intensive, and the advantages of fetching from the database are often small. The scope of Oscache's access to data is divided into application and session.

EhCache: Hibernate cache, DAO cache, security credential cache (Acegi), Web cache, application persistence and distributed cache. By default, EhCache manages the cache according to the strategy customized by the ehcache-failsafe.xml file contained in its Jar archive when the user does not provide its own configuration file ehcache.xml or ehcache-failsafe.xml. If the user provides the ehcache.xml or ehcache-failsafe.xml file under the classpath, then EhCache will use this file. If two files are provided at the same time, EhCache will use the configuration of the ehcache.xml file.
Two. SQL optimization related issues
1. Optimize query to avoid full table scan

2. Try to avoid the null value judgment of the segment in the where clause, otherwise it will cause the engine to give up using the index and perform a full table scan.

3. Try to avoid != or <> in the where clause, otherwise it will cause the engine to give up using the index and perform a full table scan.

4. Try to avoid the occurrence of or in the where clause to connect conditions.

5. Use in and not in with caution, otherwise it will lead to a full table scan

6. Do not use function operations in where.

7. In the Update statement, if you only change one or two fields, do not update all fields, otherwise frequent calls will cause significant performance consumption and also bring a lot of logs.

8. For multiple table JOINs with a large amount of data (here hundreds of them are too large), you must page them first and then JOIN, otherwise the logical reading will be very high and the performance will be poor.

9. Use varchar/nvarchar instead of char/nchar as much as possible to save space and improve query efficiency

10. select count(*) from table; this count without any conditions will cause a full table scan, and has no business meaning, it must be eliminated.

Second, the understanding of rownum and rowid in Oracle, how can I check 200 to 300 records for a thousand records?

23. How to analyze ORACLE's execution plan?

24. What are the principles, types, benefits and problems of using indexes in DB?
Principle: Because it takes a lot of time and IO to retrieve the disk comparison data, it is necessary to construct the btree, hash value, and bitmap index of a certain column of data. The general index can quickly find and compare, and the value of the index records the position of the disk, and the content of the corresponding position of the database field is directly read.

Index benefits: speed up data retrieval, speed up the connection between tables and tables, especially for the realization of data referential integrity, which has special significance, reduces the time of grouping and sorting in the query, and uses optimized hiders to improve system performance.

Disadvantages: It takes time to create and maintain an index, and the index needs to take up physical space. When the data in the table is awakened, all the data needs to be dynamically maintained.
Twenty-five, the realization principle of JVM garbage collection. Thread priority for garbage collection.
The heap space of JVM is mainly divided into young generation, old generation and permanent generation. The young generation and the old generation are objects that are dynamically generated by storage. The permanent generation mainly stores java class information, including method attributes, fields, etc. obtained by analysis. The permanent generation basically does not participate in garbage collection. The young generation is divided into an eden area and two identical survior areas. The objects created at the beginning are all placed in the eden area. This is mainly to keep objects with short life cycles in the young generation as much as possible. When there is no space available in the eden area, minorGC is performed and the surviving objects are copied to survior. The old generation mainly stores objects with a relatively long life cycle, such as cached objects. The specific JVM garbage collection process is as follows:

1. The object completes memory allocation in the Eden area. 2. When the Eden area is full, no space will be applied for when creating the object, and minorGC is triggered to perform young (garbage collection in the eden area and 1survivor area). 3. In minorGC, objects that cannot be recycled by Eden are put into an empty survior (that is, Eden must be emptied), and objects in another survivor that cannot be recycled by GC will also be put into this survivor, always guarantee one The survivor is empty. 4. When the third step is completed, if the survivor is found to be full, these objects are copied to the old area, or the survivor is not full, but some objects are old enough and are also placed in the old area. When the old area north is full, fullGC is performed.

Twenty-six, jvm maximum memory settings. Principle of setting. Talk about garbage collection.

JVM memory can be divided into heap memory and non-heap memory. Heap memory is used by developers and non-heap memory is used by JVM itself. It is used to store type information and will not release space even during GC.

Heap memory settings:

-Xms Initial heap memory, the default physical memory is 1/64, which is also the minimum allocated heap memory. When the free heap memory is less than 40%, it will increase to the maximum limit of -Xms.

-Xmx Maximum heap memory allocation. The default physical memory is 1/4. When the free heap memory is greater than 70%, the minimum limit of -Xms will be reduced.

Non-heap memory settings:

-XX:PermSize The initial value of non-heap memory, the default is 1/64 of physical memory, which is also the smallest non-heap memory.

-XX:MaxPermSize The maximum value of non-heap memory, the default is 1/4 of physical memory.

The command to view the heap size is Runtime.getRuntime().maxMemory().

Twenty-seven, how to adjust the memory size of jvm through parameters

JVM parameter settings in local environment variables:

new a JAVA_OPTS:

variable name: JAVA_OPTS

variable value: -Xms256M -Xmx512M -XX:PermSize=256M -XX:MaxPermSize=512M

Parameter settings in eclipse: input in the default VM parameters: -Xmx128m -Xms64m -Xmn32m -Xss16m

Twenty-eight, the difference between process and thread

A thread is a unit of a process and a schedulable entity within the process. The difference is: 1. The threads in the process share the address space, and the process has its own independent address space. 2. A process is the unit of resource allocation and ownership, and threads in the same process share process resources. 3. Thread is the basic unit of processor scheduling. 4. Both can be executed concurrently.

29. How to avoid deadlock

1. When using transactions, try to shorten the transaction idea logic processing process, and commit or roll back the transaction as soon as possible

2. Set the deadlock timeout parameter to a reasonable range, such as 3-10 minutes. If the time exceeds the time, the operation will be automatically abandoned to avoid process suspension.

3. Optimize the program, check and avoid deadlock phenomenon.

4. Carefully test all scripts and sp.

5. All sps must have error handling.

6. Generally do not modify the default level of sql transactions. Forcibly locking is not recommended.

30. Products and scenarios used by garbage collection algorithms

Marking-clearing algorithm: In the marking stage, all objects to be recycled are determined and marked, and the objects that need to be recycled are cleared in the clearing stage.

Copy algorithm: Divide the memory into two blocks of equal size, use one block each time, and copy the surviving objects to the other block during garbage collection, and then clean up this block of memory. The ratio of the two pieces of memory is 8:1

Marking and sorting algorithm: Move the surviving objects to one end of the memory, and then directly reclaim the memory outside the boundary. The mark-sort algorithm improves the utilization of memory, and it is suitable for the old age where the collection objects survive for a long time.

Generational collection algorithm: According to the survival time of the object, the memory is divided into the new generation and the old generation. According to the survival characteristics of the objects of each generation, each generation adopts a different GC algorithm. The new generation uses the mark-copy algorithm, and the old generation uses the mark-organization algorithm.

Three. JVM tuning in actual projects

1. JVM startup parameters: adjust the memory ratio and garbage collection algorithm of each generation to improve throughput.

2. Improve program logic algorithm and improve performance

3. Customize the package thread pool to solve the problem of long user response time. For example, set the minimum and maximum number of threads

4. Connection pool

32. Introduction to the collection of jdk concurrent packages

The Map concurrency package is implemented as ConcurrentHashMap, which implements the ConcurrentMap interface. The put method is to obtain the segment object according to the calculated hash value. After finding the segment object, call the put method of the object to complete the operation. The put method in segment is to lock first, then determine the size of the array, and then decide whether to expand. Then get the location of the key request.

List concurrency package, customers use CopyOnWriteArrayList instead of ArrayList in high concurrency environment. Adding elements is to use the copy function and locking mechanism of the array. In the case of concurrency, CopyOnWriteArrayList is slightly faster than ArrayList.

Set concurrency, the underlying implementation of CopyOnWriteSet and CopyOnWriteArrayList is almost the uniqueness judgment when adding elements, if the object array already contains duplicate elements, no increase processing is performed.

Queue concurrency, the concurrency class is ArrayBlockingQueue, the bottom layer is an array, and a locking mechanism is added to the key method enqueue and dequeue operations.

The Atomic series of classes, such as the AtomicInteger class, use a counter to operate, generally in order to avoid thread safety issues, lock operations on the method. With the atomic series class under the concurrent package, we can use it directly.

Three, communication between threads

Mainly include mutexes, condition variables, read-write locks and thread semaphores.

Mutex: Prevent data from being modified concurrently in an exclusive manner. Mutex locks two states 0 and 1. Specifically, apply for locks, occupy locks to prevent data from being modified, block by default, etc., and finally release the locks.

Condition variable communication mechanism: Principle, when the condition variable appears, it can make up for the defects of the mutex. Some problems cannot be solved by relying only on the mutex. However, condition variables cannot be used alone, and must be combined with mutex locks to achieve mutually exclusive access to resources.

Read-write lock: When reading and writing data, reading often accounts for the main part. The basic principle is that if other threads read data, other threads are allowed to perform read operations, but write operations are not allowed. If other threads apply for write operations, other threads cannot apply for read operations and write operations.

Thread signal: The thread has private data related to the signal-the thread signal mask. Threads can send signals to other threads, and each thread can set its own blocking set. In all threads, the processing of the signal in any thread of the same signal must be the same.

Three or four, introduce threadlocal

It can be called thread local variable or thread local storage. ThreadLocal creates a copy of the variable in each thread, and each thread can access its own internal copy variable. However, doing so may result in a larger memory footprint.

Several methods of the ThreadLocal class: get() is used to obtain a copy of the variable saved by ThreadLocal in the current thread, set() is used to set a copy of the variable in the current thread, and remove() is used to flush the copy of the variable in the current thread. initialValue() is generally used to rewrite when in use, and is a lazy loading method. The most common ThreadLocal usage scenario is to solve database connection, Session management, etc.

35. The operation process of jdbc

Load the database driver package, connect to the database, use SQL statements to operate the database, and close the database connection

36. New features of HTTP 1.1

Support continuous connection. After establishing a TCP, send a request and get a response, and then send more requests and get more responses. By apportioning the cost of resume and TCP connection release to multiple requests, the relative cost of being superior to TCP for each request is greatly reduced. And you can also send pipeline requests.

37. Exception handling, what is included


38. Heap sort and quick sort

View Code

View Code

Heap sorting is a progressively optimal comparison sorting algorithm, reaching the lower bound of O(nlgn), and fast sorting has a certain possibility of producing the worst division, and the time complexity may be O(n^2). Almost none of the stack comparisons are adjacent elements, which is extremely unfriendly to the cache. The mathematical complexity does not necessarily represent the complexity of the actual operation.

39. What are the classes of Collection

Set, List, Map, SortedSet, SortedMap, HashSet, TreeSet, ArrayList, LinkedList, Vector, Collections, Arrays, AbstractCollection

Forty. What happens if Hashcode is always 1, and how to resolve hash conflicts

When all object Hashcode returns are 1, all objects have hash conflicts, and their performance will decrease

Resolve hash conflicts:

In the linear re-hashing method and inserting elements, if there is a conflict, the algorithm will simply traverse the hash table until it finds the next empty slot in the table, and put the element in that slot. When searching for an element, first hash the slot pointed to by the hash value. If no match is found, continue to traverse the hash table until: (1) find the corresponding element; (2) find an empty slot (indicating that the searched element does not exist); (3) The entire hash table has been traversed (indicating that the element does not exist and the hash table is full).

The non-linear rehashing method and linear rehashing method start from the conflict position and use a step size to traverse the hash table in a sequential manner to find an available slot. As can be seen from the above discussion, it is prone to clustering. The non-linear rehashing method can avoid traversing the hash table. It calculates a new hash value and jumps to a completely different part of the table through it.

In the external zipper method, the hash table is regarded as an array of linked lists. Each slot in the table is either empty or points to a linked list of entries that are hashed to that slot.

41. How to use two queues to implement a stack

That is, the A queue can be used as a stack push, and the B queue can be used as a stack pop. The volume queue data is the same.

42. The general method of Object

Common methods are equals(), finalize(), toString(), and other native methods are hashcode(), registerNatives(), getClass(), clone(), notify(), notifyAll(), wait(), etc.

Fourth, how to achieve polymorphism in Java

Polymorphism is an important feature in OOP, which is mainly used to implement dynamic binding. The final state of the program is only determined during execution rather than during compilation. Conducive to improving the flexibility and scalability of large-scale systems.

Three necessary conditions for polymorphism: inheritance, method overriding, and parent class references pointing to subclass objects.

There are two types of reference variables: the compile-time type is determined by the declared type, and the runtime type is determined by the actual corresponding object.

View Code

View Code

Polymorphic memory:

Fourth, Java memory leak

Memory leaks generally have two situations: In C++/C, the memory allocated in the heap is deleted without releasing it and all the ways to access this memory are deleted. (Such as pointer reassignment)

Another situation is that when the memory object is no longer needed, the memory and its access method (reference) are still reserved. Due to the GC mechanism in Java, memory leaks in Java usually refer to the second situation.

Although for memory leaks in C/C++, Java memory leaks are less destructive, except for a few cases where the program crashes, the program can still run normally in most cases. However, when mobile devices have strict restrictions on memory and CPU, Java memory overflow can cause problems such as low program efficiency and occupying a large amount of unnecessary memory. This will cause the performance of the entire machine to deteriorate, and in serious cases it will also cause OutOfMemoryError to be thrown, causing the program to crash.

Without involving complex data structures, a Java memory leak manifests itself as the life cycle of a memory object exceeds the length that the program needs it. (Called subject free).

Examples of memory leaks: Java heap overflow, virtual machine stack and local method stack overflow, method area and runtime constant pool overflow, native direct memory overflow

Four or five, final field summary

1. The final class cannot be inherited, and the methods in it are also the default final type, and there are no subclasses.

2. Final method cannot be overridden by subclasses, but can be inherited

3. Final variables represent constants and can only be assigned once and do not change after assignment

4. Final cannot be used to construct a method

Forty-six, the difference between override and overload

override: When the subclass inherits the parent class, the subclass can define certain methods that are consistent with the method name, number of parameters, type, order, and return value type of the parent class, but the method of the subclass is automatically invoked when calling, which is equivalent to the parent class. Yu was covered.

Overload: can be expressed in the polymorphism of the class, the function name is the same, but the number, type, order, return value, etc. of other parameters are not the same.

Four seven, static initialization

Uninitialized global static variables will be automatically initialized to 0.


I cannot guarantee that everything I write is correct, but at least I can guarantee that it will not be copied or pasted, and that every sentence and every line of code has been carefully considered and carefully considered. Behind every article, I hope to see my attitude towards technology and life.

I believe what Jobs said, only those who are crazy enough to think they can change the world can really change the world. In the face of pressure, I can use the lamp to fight night and sleep endlessly; in the face of difficulties, I am willing to face the difficulties and never back down.

In fact, what I want to say is that I am just a programmer, and this is all of my pure life now.

Finally, I hope you can support the one-click triple connection + comment and present my own "Dachang Zhenti + Microservice + MySQL + Distributed + SSM framework + Java + Redis + data structure and algorithm + network + Linux + Spring family bucket + JVM+ High concurrency + major learning mind map + interview collection"