java-based surface finishing 2020.1.15 questions

Serialization and de-serialization

Serialization: the state of the object into a byte code procedure is called serialization.
transient modified properties are not serialized.
Static static properties are not serialized.

Deserialize: restoring byte sequence deserialized object is called an object.

  1. In what way are serialized
    implements the Serializable interface.
    Hessian serialization
    Json serialize

  2. Note that in the sequence of several points
    transient property can be modified, to prevent the property is a sequence of
    static attribute will not be serialized.
    Subclass can inherit function sequence of the parent class
    reference type as the property of the target sequence and the sequence
    i.e. a sequence of object a, b properties of an object without a reference sequence of the interface can be implemented with a target sequence of the serialization; actual otherwise, the object class b also need to implement the interface in order to serialize a serialized object as being serialized.

  3. The sequence of action
    when persistent storage.
    When the network transmission.
    RMI through the transport object.

The difference between sleep and wait

These two methods are from different categories, namely from sleep thread class, object class wait from
the main method is not sleep release the lock, the lock release wait method, other threads can be sync control blocks and
range: wait, notify, notifyAll only synchronous or synchronous control method for use inside the control block, and sleep can be used anywhere.
sleep must catch the exception, and wait, notfy, notifyAll do not need to catch the exception

Initialize an array of ways

Dynamic Initialization: Array array separately defined space allocation and assignment operation;
static initialization: defining an array while the array element and the space allocated for the assignment;
default initialization: the array is a reference type, whose elements corresponding to members of the class variables, each element of the array is allocated space according to the rules implicitly member variables initialized

String,StringBuffer,StringBuilder区别

  1. If variable length
    String is final modification, the bottom is a modified final byte array. (Incomplete immutable, can be forced to change the assignment mechanism by reflection) are not described here.
    And a variable object StringBuffer StringBuilder class.
  2. Efficiency
    Stringbuilder> StringBuffer> String
  3. Application scenario
    if the amount of data to be operated with = String
    large single-threaded operating = StringBuilder data string buffer operation
    multithreading operating string to buffer large amounts of data = StringBuffer
  4. Are thread-safe
    StringBuffer is thread-safe, thread-safe way to achieve all of these methods are combined with the synchronized keyword modification, and therefore is thread-safe, StringBuilder methods without adding modified so insecure.

java object-oriented features

They are encapsulation, inheritance, and polymorphism.

  1. Encapsulating
    the data and methods of operation data bind. And name, no need to consider internal implementation, named only need to call the corresponding name when used. This is encapsulated
    inside to provide better encapsulation class, the class can be hidden inside the other classes in the package does not allow access within the outer class the class
    method of an internal class can access all the data directly to the external class, including private data.
    Using an external function within the class class implements can achieve the same, but sometimes more convenient to use the inner classes.

Inner class can be divided into the following categories:
members of the inner class
static inner class
method inner classes
Anonymous inner classes
postpone doing deep research. Internal class can provide better encapsulation.

  1. Inheritance
    is a relationship Inheritance is class and class, is a is a relationship. Animals such as dogs inherit. java in inheritance single inheritance is that a class has only one parent.
    The benefits of inheritance, the subclass has all the properties and methods of the parent class (modified to be private property not owned)

  2. Polymorphism
    allows different types of sub-stacks in the same state information for the different responses. Mainly between the sub-classes and superclasses. The main achievement is to rewrite and overloading

What are rewritten and overloading

  1. Rewriting subclass that implements the method allows access to the parent class rewrite process, return values, and can not change parameter.
    Rewrite the benefits of
    that subclass their behavior in accordance with needs, define specific. That subclasses reimplement the parent class according to their needs
    method override can be summarized as a large two small two with
    a big: a subclass can access the same large or
    two small: subclass and return value type exceptions thrown only smaller, then the type can be converted.
    With two: the same method name and parameter
  2. Overload is a class, a method of the same name have different parameter list. Overload of the return type is not required, it may be the same or different, but the same can not be determined whether the return type overloading.

cookie和session

  1. Different data storage location:
    the cookie data is stored on the customer's browser, session data on the server.
  2. Different security levels:
    cookie is not very safe, people can analyze stored in a local cookie and cookie can be used to deceive taking into account the security session
  3. Use different degree of performance
  4. session will be saved on the server for a certain time. When accessing the increase would be more occupy your server's performance, taking into account mitigating server performance, you should use the cookie.
  5. Different data storage sizes:
    single cookie saved data can not exceed 4K, many browsers are limited to a maximum of 20 sites saved cookie, but session is stored with the server, the browser is no limitation thereto.

session in the role mabatis

mybatis the session is a transaction and cache manager.

Abstract classes and interfaces

  1. Abstract class
    abstract class (abstract modification) can not be instantiated, inheritance can only be used
    subclasses of the abstract class should provide implementations for all the abstract methods, if not all subclasses rewritten, the abstract class is a subclass
    of abstract class the method may comprise non-abstract
    abstract class reference to examples directed subclass
  2. Interface
    Interface (interface modifications). Interface methods are all abstract methods, static methods can have jdk1.8 then, by default, and modified (and both methods may be present in the method body)
    interface variables constant (static Final)
    interfaces can not be instantiated, only It can be implemented, the interface can be inherited
    interface implementation class of all methods in the interface must be implemented, if not possible subclasses will become an abstract class.
    Interface can achieve multi-
    interface multiple-inheritance
    interface reference point to achieve the instance of the class

Automatic boxing and unboxing automatic

Automatic boxing and unboxing package type is provided for each of the original Java class
main role is to facilitate the conversion between the basic data types.

Java basic data types

Four eight kinds:
Integer: byte (1), short ( 2), int (4), long (8)
floating point: float (4) double (8 )
Character: char (2)
Boolean: boolean (1)

  1. int type to a String
String.valueOf(1111;
String a=1+"";

If the corresponding wrapper class can call toString ();

  1. String to type int
    call parseXxx () method with the type of package base class.
int a=Integer.parseInt("1111");

final, finally, finalize the difference

  1. final
    the final modification of immutable classes can not be modified, can not be inherited. (Contrary to the reflection package, incomplete immutable)
    is a modified final variables can only be assigned once, can not be modified later.
    The modified final methods can not override the (covered)
  2. finally
    finally
  3. finalize
    each object has this method, when the JVM garbage collection calls the finalize method, after the second call to the object to be cleaned up, free up memory.

Articles are free to make, if the concept wrong place enthusiastic users want to point out to learn together.

Published 24 original articles · won praise 1 · views 556

Guess you like

Origin blog.csdn.net/qq_45366515/article/details/103956089