Summary of issues (b)

1. Java What are four ways to create an object?

  • new
 Students s1 = new Students()
  • clone
Students s2 = (Students) s1.clone();
  • reflection
 Class clazz = s1.getClass();
 Constructor constructor = clazz.getConstructor();
 Students s2 = (Students) constructor.newInstance();
  • Object deserialization
 ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(file));
 out.writeObject(s1); //把s1对象写入到文件中。
 ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
 Students s2 = (Students) in.readObject();

2. What is maven? What are the core functions of the maven?

definition:

  • Architecture is a maven project management tool for easy import into a jar package , its core idea is: the agreement is greater than the configuration .

Core functions:

  • Dependency management
    example: dependent service
<dependencies>
  <dependency>
          <groupId>com.shsxt</groupId>
          <artifactId>wc-service</artifactId>
          <version>0.0.1-SNAPSHOT</version>
  </dependency>
</dependencies>

groupId: actual project belongs - Company Name
artifactId: - module project name
: project in which the current version version

Usually required libraries to find website: http: //mvnrepository.com/

And then copied to the pom.xml file, remember to write notes and dependencies in the project, save it relied.

  • Management modules
    need to be defined as a set of a parent module POM POM polymerization in Maven. The labels may be used to define a set of POM submodules. parent POM does not have any actual build output. The parent POM in the build configuration and dependency configuration are automatically inherited by the child module.
    E.g. pom.xml submodule configured as follows:
<modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.hbgc</groupId>
        <artifactId>base</artifactId>
        <version>1.0-SNAPSHOT</version>
        <!--父模块的pom.xml位置-->
        <relativePath>../base/pom.xml</relativePath>
    </parent>
    <groupId>com.hbgc</groupId>
    <artifactId>springbootdemo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>springbootdemo</name>
    <description>Demo project for Spring Boot</description>
  • Plugin Manager
    to add plug-ins, similar to adding a dependency to specify the plug-in by GAV, which for the official maven plugin, you can omit GroupId.
    For example:
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-clean-plugin</artifactId>
            <version>3.0.0</version>
        </plugin>
    </plugins>
</build>
  • Deployment Manager
    in the idea, we can open maven project view. Test, package, and installed in the list maven life cycle.
    Here Insert Picture Description
    In addition, Maven has three life cycle: clean, default (the core), site

3. What is MVC? Talk about the benefits of stratification.

MVC is a framework, or is a design pattern, it is the mandatory application of the input, processing and output separately. An application into three parts: the Model, View, i.e. the Controller model, view and controller.
Model:

  • Business deal: business logic (Service)
  • Data Persistence: CRUD (Dao)

View:

  • Display data
  • Servlet provides a link to initiate a request (a, form, img ...)

Controller (Servlet):

  • Receiving a user's request: (req: request parameter, Session information ....)
  • Layer processing to the service code corresponding to
  • Jump Control view

Layering is reflected in the MVC design pattern.
The benefits of layered is decoupled, so that high cohesion and low coupling .

What 4. Spring's two core technology?

(1) IOC (DI): Inverse of Controller, controls reversal
Dependency Inject, dependency injection.
Two is one thing, is called the cat had a microphone.

How to understand the dependency injection it?
① create objects never new new
② Interface-Oriented Programming

(2) AOP: Aspect-Oriented coding

5. What is the IOC / DI?

IOC: i.e. inversion control , the most basic out by the calling object is a new object, such as: People p = new People () , we Spring framework calls IOC i.e. change in this way, the rear "new People" Conversion to call for the xml files that use a third party call.

DI: That dependency injection , is a specific implementation technology, is responsible for an instance variable means (implemented class) passed by a third party component to the object (call the class) to go.

6. The difference between the turn-Oriented Programming Object-oriented programming interface.

  • First, oriented programming interface belongs to an object-oriented system of thought, it is a part. Or that it is one of the essence of the idea of ​​object-oriented programming system.
  • Object-oriented programming: java is object-oriented programming, called in java objects are all things, this is because all the java classes are new calls out, followed by the object-oriented uses three characteristics, namely, encapsulation, polymorphism, inheritance .
  • Oriented Programming Interface: In the system architecture and analysis, to distinguish between levels and dependencies, each level is not a direct service to its upper layer, but by defining a set of interfaces, which interface functions exposed only to the upper, the lower layer only to the upper layer interfaces dependence, independent of the specific type. Doing a lot of good for the flexibility of the system, when the lower needs to be changed, as long as the interfaces and interface functions constant, the upper layer without any changes.
  • In short: Object-oriented programming is a pile of objects, by encapsulation, inheritance, polymorphism and other procedures more efficient organization; oriented programming interface is a pile of interfaces, properties and methods by Interface Specification object, object-oriented part.

7. What is a reflection? Reflection is talk about how to apply to the spring frame.

  • Reflection mechanism is in the operating state, for any class, are made known to all properties and methods of this class; for any object, are able to call any of its methods and properties.
  • Xml file by parsing, to acquire the content attribute id and class attributes which acquires the configuration inside the object class instance using a reflection principle, the deposited into Spring bean container.

8. What to talk about java xml parsing technology?

(1) DOM
advantages:

  • Forming a tree structure, easy to understand intuitively, the code easier to write
  • Parsing tree structure remains in memory, making it easy to modify

Disadvantages:

  • When the xml file is large, memory consumption is relatively large, easily affect performance and cause memory overflow parsing

(2) SAX
advantages:

  • Event-driven mode, memory consumption is relatively small
  • When applied to only need to process data xml

Disadvantages:

  • Easy coding
  • Difficult to simultaneously access multiple different data in the same xml

(3) Jdon

  • Only concrete classes using the interface without using
  • API extensive use of Collections class

(4) Don4j

  • An intelligent branch of JDOM, it incorporates many features beyond basic xml document representation
  • Use interfaces and abstract base class methods, it is a good Java XML API
  • With excellent performance, good flexibility, powerful and extremely easy-to-use features
  • It is an open source software

DOM4J and JDOM in the actual development with more third-party analytical techniques.

9. The difference between abstract classes and interfaces.

Abstract class is to reuse the code , and use the interface to achieve polymorphism , particularly the following differences:

(1) member of difference

 抽象类:
	成员变量:可以变量,也可以常量
	构造方法:有
	成员方法:可以抽象,也可以非抽象
 接口:
	成员变量:只可以常量
	成员方法:只可以抽象	

(2) the relationship between the difference

类与类:
	 继承,单继承
类与接口:
	实现,单实现,多实现
接口与接口:
	继承,单继承,多继承	

(3) design difference

抽象类: 	被继承体现的是:”is a”的关系。	抽象类中定义的是该继承体系的共性功能。
接口:	被实现体现的是:”like a”的关系。	接口中定义的是该继承体系的扩展功能。

For example: a mug cup, having a thermal insulation function. Mug cup extends implements insulation, glass is an abstract class, an interface insulation.

10. talk about the form of synchronous and asynchronous submit distinguish submitted.

  • Synchronization submit the form: Form submission default behavior is to synchronize submitted, the browser will lock up waiting for a response result of the service side.
    No matter what is the response of the server will respond directly to the result of overwriting the current page. (Only for the synchronization server redirects submit valid)
  • Asynchronous submission form: form internal label no longer write action and method, but to achieve by submitting the url ajax method and option forms submitted content does not lock occurs, any browser can then do other things.
  • At present, enterprises project, presented in a way most use asynchronous, synchronous submission rarely used.
Published 62 original articles · won praise 2 · Views 2722

Guess you like

Origin blog.csdn.net/nzzynl95_/article/details/104318678