Sophisticated interview questions (seven)

java is how to achieve the underlying notes

Bottom annotation is implemented using the reflection

Springboot you wrote it, which he notes there

The advantage of using annotations:

     1. pure java code, does not require complicated configuration xml file

     2. In the configuration may also enjoy the benefits of object-oriented brought

     3. Type the security of the reconstruction can provide good support

     4. At the same time reduce the complexity of the configuration file can also enjoy the functionality provided by the container springIoC

@SpringBootApplication: Affirming let spring boot automatically makes the necessary configuration to the program, this configuration is equivalent to: @Configuration, @ EnableAutoConfiguration and @ComponentScan three configurations.

 

@ResponseBody: indicates that the method returns the result directly written HTTP response body is generally used in the asynchronous data acquired for constructing the api RESTful. @RequestMapping after use, the return value is typically resolved as the jump path and, with the results returned @esponsebody not be interpreted as the jump path, but directly written in the HTTP response body. Such as asynchronous get json data, after adding @Responsebody, it will return json data directly. The Notes will generally be used in conjunction with @RequestMapping.

 

@Controller: a controller for defining classes in the spring by the controller responsible for the project forwards the URL request sent by a user to the corresponding service interface (service layer), generally in the annotation class annotated with the conventional method requires @RequestMapping .

 

@RestController: a control layer label assembly (e.g., the action struts), @ ResponseBody @Controller and the collection.

 

@RequestMapping: provides routing information, URL mapping to the Controller responsible for specific functions.

https://blog.csdn.net/weixin_40753536/article/details/81285046

java logging framework used which

Laog4j 

slf4j 

Commons Logging

 

What are the top java parent class method

Top Java parent class -Object

protected Object clone () Creates and returns a copy of this object. 
boolean equals (Object obj) indicating whether some other object with this object is "equal." 
protected void finalize () when the garbage collector to identify additional references to the object does not exist, this method is called by the garbage collector objects. 
Class <? ExtendsObject> getClass () returns an object runtime class. 
int hashCode () Returns the hash code value for this object. 
void notify () wake up a single thread waiting on this object's monitor. 
void notifyAll () wakes up all threads waiting on this object's monitor. 
String toString () Returns a string representation of the object. 
void wait () Causes current thread to wait until another thread invokes the object's notify () method or the notifyAll () method. 
void wait (long timeout) Causes current thread to wait until another thread invokes the object's notify () method or the notifyAll () method, or more than a specified amount of time. 
void wait (long timeout, int nanos ) Causes current thread to wait until another thread invokes the object's notify () your company's java writing specifications

       Our company Alibaba development standard reference code writing.

MySQL implementation plan

       Explain

And the difference between hashmap treemap the know

HashMap TreeMap non-thread-safe non-thread-safe

HashMap is a realization Map interface hash table-based, TreeMap: red-black tree implementation based on

HashMap result is not sorted, and the result is outputted TreeMap sorted

HashMap is generally a bit faster than TreeMap (data tree and hash table dictates), it is recommended to use HashMap, in the Map when you need to sort it by TreeMap

 

What are some ways to traverse a hashmap

       Approximately 5 ways

// 1 and used for reinforcing keySet () method

    // to use the Map interface keySet () method to get the return value set <k> object, or an array called
    the Set <Integer> = S h.keySet ();
    // At this time, the key value is obtained
    // iterate using enhanced for
    for (Integer I: S)
    {        
        // is the key I
        // use the Map interface gET (key) method returns the value corresponding to the value
        system.out.println (h .get (I));
    }

. 2 // used for reinforcement and Iterator, keyset traverse        
    // Map interface to use keySet () method to get the return value set <k> object, or an array called
    Set <Integer> s = h.keySet ();
    // use iterator Iterator interface () method returns a value of Iterator <E> objects, SET inherited Collection
    // it has iterator () method can be used directly
    Iterator i = s.iterator ( );
    // iterate used for reinforcing
    the while (i.hasnext ())
    {
        system.out.println(s.get(i.next()));
    }

//3.使用entrySet()和增强for
        Set<Map.Entry<Integer, String>> s3=h.entrySet();
        for(Map.Entry<Integer, String> m:s3)
        {
            System.out.println(m.getValue()+m.getKey());
        }

//4.使用entrySet()和Iterator
        Set<Map.Entry<Integer, String>> s4=h.entrySet();
        Iterator<Map.Entry<Integer, String>> i2=s4.iterator();
        while(i2.hasNext())
        {
            Map.Entry<Integer, String> a=i2.next();
            System.out.println(a.getValue()+a.getKey());
        }

//5.只能遍历到内容的方法
        //Collection<String> c2=new ArrayList<String>();
        Collection<String> c=h.values();
        //ArrayList<String> a=(ArrayList<String>)c;
        
        for(String s:c)
        {
            System.out.println(s);
        }*/

The relationship between the list and arraylist

List is an interface, and ArrayList is a class that implements the List interface. ArrayList class inherits and implements List interface. Therefore, the List interface can not be constructed, that is, we are talking about can not create an instance of an object, but we can as a reference as follows List interface to create a link to its own object, and instance objects ArrayList implementation class in this act as the point List object interface references.

List a = new ArrayList ();
then a List have all the properties and methods, will not have its unique properties and methods of implementing class ArrayList. If List and ArrayList has the same properties (e.g., int i), the same methods (e.g., void f ()), the ai is called the List i, af () is called the ArrayList F ();

 

hashmap is how to get and put, that is how it is done

get method calls

Hash function calls 1. When calling the get method hashCode this key value will hash function returns, the return array length - 1 Entry hashCode and logically ANDs obtain a value index, this index value is used to determine the data stored in the Entry position among the array

2. The index position corresponding to traverse the list through the loop, the initial value of the position data stored in the array Entry among cycling conditions for the Entry object is not null, the loop condition is changed next node object Entry

3. If the hash value of the hash function obtained Entry object among the key hash values ​​are equal, and the key value among Entry object passed in the get method and the key value equals the value of the same value Entry object is returned, otherwise null

put method invocation

1. hash function calling key value obtained HashCode

2. The index values ​​to obtain a value of the array length -1 HashCode logical AND operation

3. traversing the index position corresponding to the list, the hash value of the hash with the hash function if the Entry object obtained equal, and the key value and put the Entry Method pass over the object is equal to the key value, the value of the object value assigned Entry to a variable, the value of the value Entry object to re-put method set pass over the value argument. The old value is returned.

4. Add Entry object corresponding to the position index

https://blog.csdn.net/linsongbin1/article/details/54667453

Guess you like

Origin www.cnblogs.com/lingboweifu/p/11909794.html