1. What is the difference between a static variable and an entity variable?
Static variables, which can be directly interviewed by the class name
Memory differences: When static is defined, the JVM allocates space,
The entity variable only allocates space when the object is created.
2, int integer difference?
Integer is the wrapper class for Int.
An Integer is an object. Default value of Null,int is 0
3, public protected friendly the difference between private?
Currently similar to a package inheriting class different packages
Public√ok OK OK
Protected√ok OK no
Friendly√ok No No
Private√no No No
4. What is the difference between overloading and rewriting?
Overload Overload: Method Name Similarly, the number of parameters is different
Overwrite rewrite: Another write to the parent class method
5, Database Paging query
Oracle:select * FROM (SELECT * from table where Romnum >0) where Romnum <20;
Mysql:select * FROM table limit 0,20
6, WebService?
Enterprise-published services are able to access and invoke today's services over the Internet.
Hardware platforms, operating systems, and programming languages to implement services
The main composition has wsdl:web service descriptive narrative language
7. What are the characteristics of SOA?
can be reused
Loose coupling
8, WebService
JAX-ws
Cxf
9, the difference between abstract class and ordinary class:
The only difference between an abstract class and a normal class is that it cannot create an instance object and agrees to have an abstract method;
10, the difference between the abstract class and interface:
Abstract class and interface are two of the ways in which abstractions are defined in the Java language, and they have a very large similarity.
However, the choice of them often reflects the understanding of the nature of the concepts in the problem domain, the correct reflection of the design intent,
reasonable, as they represent the different relationships between concepts (although all can achieve the function of demand).
This is actually a way of using language.
To summarize a few words:
Abstract classes and interfaces cannot be instantiated directly, given the assumption of instantiation. An abstract class variable must point to a subclass object that implements all the abstract methods.
The interface variable must point to the class object that implements all the interface methods.
Abstract classes are inherited by subclasses, and interfaces are implemented by classes.
The interface can only do the method declaration, the abstract class can make the method declaration, also can do the method realization
The variables defined in the interface can only be public static constants. A variable in an abstract class is a normal variable.
Abstract methods in abstract classes must be implemented by all quilt classes. If the subclass cannot all implement the parent class abstract method, then the subclass can only be an abstract class.
Same. When an interface is implemented, the class can only be an abstract class if it cannot implement all the interface methods.
Abstract methods can only be stated. cannot be achieved.
abstract void ABC (); cannot be written as abstract void abc () {}.
Abstract classes can have no abstract methods.
Suppose there is an abstract method in a class. Then this class can only be an abstract class
Abstract methods are implemented, so they cannot be static or private.
Interfaces can inherit interfaces. And can inherit multiple interfaces, but the class can inherit only one root.
Inversion of control: to eliminate the application's dependency on plug-in implementations, dependency injection is not the only option
IOC: Dependency Injection: There are three major forms of dependency injection.
I call them the constructor injection (Constructor injection), respectively.
Set Value method Injection (Setter injection)
and interface Injection (Interface injection).
Assuming you've read some recent discussions about the IOC, it's not hard to see:
The three injection forms are type 1 IOC (interface injection), type 2 IOC (set value method injection), and type 3 IOC (constructor injection).
The so-called AOP, Aspect orientied program, is aspect-oriented programming,
2. Explain what is the aspect: a system that runs through the various modules of the system one function is one aspect,
For example, logging, unified exception handling, transaction processing, and full-limit checking. These features are software systems
A face, not a point, appears in each module.
3. What is aspect-oriented programming: The function of one aspect of the system is encapsulated into an object form to handle
4. How to do aspect-oriented programming: the corresponding object of the function module is embedded in the original system module as a slice.
Using proxy technology, the agent invokes the target, adding the code (object) of the tangent function at the same time. So
When you configure proxy objects with spring, you only need to have two properties, representing the target and tangent objects (Advisor).
IOC is the instance interface or instance class given to the IOC container (assuming that the factory model is understood as an IOC is fine)
AOP is the weaving technology, plainly, want to achieve the effect is in the method before running. Post-run dynamic Insert method
First of all, AOP, in fact, is very easy, is to wrap your returned instance, put this instance of each method before the Increment method,
There are no IOC words here. Then this implementation will expose the ape to the program. After the IOC was added, it was perfect.
The process is that the IOC goes to the instance object. When the instance is called, the AOP program is re-packaged for this object.
The last object returned to the programmer is the wrapped object, so simple. As for how to achieve, there are very many ways
The most typical is sprint.net, which is implemented by emit in reflection.
IOC: Control inversion is also called dependency injection. Using the factory model
Give the object to container management. You simply have to configure the appropriate bean in the spring configuration file, and set the related properties so that the spring container generates the instance object of the class and manages the object.
When the spring container is started, spring initializes the beans that you configured in the configuration file, and then, when you need to invoke them, assigns the beans that are already initialized to the class you need to invoke them (assuming the class name is a), The method of allocation is to call a setter method to inject, without needing you to new these beans in a.
Note: During the interview. Suppose there is a condition, drawing, so much so that you understand
AOP: Plane-oriented programming. (Aspect-oriented programming)
AOP can be said to be complementary and intact to OOP. OOP introduces concepts such as encapsulation, inheritance, and polymorphism to create an object hierarchy that simulates a collection of public behavior. When we need to introduce public behavior to scattered objects, oop seems powerless.
Other words. OOP agrees that you define relationships from top to bottom, but it is not appropriate to define a left-to-right relationship. such as the log function. Log codes tend to be spread horizontally across all object hierarchies. And it has nothing to do with the core functions of the objects it spreads. In OOP design, it leads to a lot of code repetition. and is not conducive to the reuse of various modules.
The cross-business logic in the program (such as security, logs, transactions, etc.) is encapsulated into a slice and then injected into the target object (the detailed business logic).
Technology to implement AOP. Mainly divided into two categories: first, the use of dynamic Agent technology, the use of interception of messages, the message is decorated to replace the original object behavior of the operation. The second is the use of static weaving in a way to introduce a specific syntax to create "aspects", so that the compiler can be in the compilation of the "aspect" of the code
Simply explain, for example, that you want to add a print ' hello ' function to all classes in your Biz layer, which you can do with AOP, write a class and write a method first. The method is implemented to print ' Hello ' after you have the IOC of this class ref= "biz.*" to let each class inject.
Database various connection differences:
Left Join,right Join,inner join (join)
The left join is relative to right join:
Main example: SELECT * FROM table1 T1 left join table2 t2 on t1.col1 = t2.col2;
This time the results are as follows: All collections of Table1, table2 parts of the collection
Suppose you want to find all the collections of table2: You can use RIGHT join:
SELECT * FROM table1 T1 right join table2 t2 on t1.col1 = t2.col2;
Inner JOIN is exactly the same as join. The intersection of two tables is found.
SELECT * FROM table1 t1 inner joins table2 t2 on t1.col1 = t2.table2 where t1.id = 1;
The base data type contains byte, int, char, long, float, double, Boolean, and short.
Nine major package categories: byte,integer,char,long,float,double,boolean,short,string;
How threads are implemented:
Inherit the thread class to implement the Runnable interface. Through the thread pool way to achieve
The difference between the sleep (), Wait () methods:
Sleep () The current thread is paused, yielding CPU resources to other threads to run. Monitoring status is still the same. But sleep () does not abandon object locks.
Wait () The current thread discards the object lock, enters the waiting state, only has the ability to be awakened when notify.
However, sleep () will go into operation immediately after the thread has finished running.
Differences between Java basic types and encapsulation classes
1. Basic types can only be passed by value. The corresponding encapsulation class for each base type is passed by reference.
2. In terms of performance, the basic types in Java are created on the stack. All object types are created on the heap. (The object's reference is created on the stack).
3. The appearance of the encapsulation class. is to make it easier to use some basic types of methods that are not available, such as valueof (). ToString () and so on.
4. Pretend to pass a reference to an int object instead of a value, which can only be used with encapsulation classes.
5. The basic data can be encapsulated into the package class, the basic data type of the advantage is fast (not related to the construction and recycling of objects), the purpose of encapsulation class is to better handle the conversion between the data. The method is very much, it is convenient to use.
[The efficiency of the call to allocate memory on the stack and the allocation of memory on the heap is much worse.]
Despite the high efficiency of allocating memory on the stack. There is only a memory leak in the allocation on the stack. ]
23 Design Patterns in Java:
Factory (Factory mode), builder (build mode). Factory Method (Factory mode).
Prototype (original model mode), Singleton (singleton mode). Facade (façade mode),
Adapter (adapter mode), Bridge (bridge mode), Composite (synthetic mode).
Decorator (decorative mode), Flyweight (enjoy meta mode). Proxy (agent mode),
Commands (Command mode). Interpreter (interpreter mode), Visitor (reader mode).
Iterator (iterative sub-mode), Mediator (mediator mode), Memento (Memo mode),
Observer (Viewer mode), State (status mode), strategy (policy mode),
Template method (pattern mode), Chain of responsibleity (responsibility chain mode)
Factory mode: Factory mode is a pattern that is often used. Classes implemented according to the factory pattern can generate an instance of a class in a set of classes based on the data provided, usually having a common abstract parent class and implementing the same method, but these methods do different things for different data. First, you need to define a base class in which subclasses implement the methods in the base class in different ways. Then you need to define a factory class that can generate different subclass instances based on conditions. When you get an instance of a subclass. Developers can call methods in the base class without having to consider which instance of the subclass is returned.
Java Interview Summary