Java Exercise Exercises
1.
Dependency injection and control inversion are the same concepts:
Dependency injection and control inversion are different descriptions of the same thing, and in one way or another, they describe different angles. Dependency injection is described from an application perspective, where dependency injection can be described as the complete point: The application relies on the container to create and inject the external resources it needs, while control inversion is described from the container's perspective, describing the complete point: container control applications, the external resources required by the container to inject the application into the application in reverse.
2.
C
When the Load method is used to get an object, Hibernate uses the mechanism of lazy loading to load the object, that is, when we use the Session.load () method to load an object, the SQL statement is not emitted at this time, and the currently obtained object is actually a proxy object. This proxy object only holds the ID value of the Entity object, and only if we want to use this object to get other attributes, we will issue the SQL statement and query our object from the database.
The get is much more straightforward than load lazy loading, and when we use the Session.get () method to get an object, regardless of whether we make the object non-use, the SQL statement is issued to query the database.
1. Hibernate2 Deferred load implementation: a) collection of entity object B) (Collection)
2. Hibernate3 provides properties for lazy loading functions
When hibernate is querying the data, the data does not exist in memory, and when the program actually operates on the data, the object exists in memory, and the delay is loaded, which saves the server's memory overhead and improves the performance of the server.
An> is a JDBC-based, mainstream persistence framework that is an excellent ORM implementation. He simplifies the coding of the DAO layer to a great extent
3. Hibernate uses the Java reflection mechanism rather than the bytecode enhancer to achieve transparency.
4. Hibernate performs very well because it is a lightweight framework. The flexibility of the mapping is excellent. It supports a variety of relational databases, from one-to-one to many-to-many complex relationships.
3.
Suggest to see this blog entry easy to understand http://blog.csdn.net/sivyer123/article/details/17139443 simply speaking, Java's heap memory is divided into two blocks: Permantspace (persistent band) and heap Space The persistence belt is mainly used for storing static type data, such as Java Class, Method, etc., and the garbage collector to collect the Java object is not very related. And Heapspace is divided into young and old generation of garbage collection called Young GC, old generation garbage collection called Full GC. Objects that survived after N (configurable) garbage collection in the young generation are copied into the old generation. Therefore, it can be considered that older generations are stored in older generations of objects that have long life cycles. The cause of the old generation overflow is the processing of tens of thousands of strings, the creation of thousands of objects, the application of hundreds of M or even a g of memory within a code, a B-d option for persistent overflow causes the overflow 4, All of these methods are strategies for resolving the hash conflict, but in Java.util.HashMap, the chain address method is used in general to resolve conflicts. Of course, the use of the chain address method causes the efficiency of get to be reduced from O (1) to O (n), so in Java8, the balance tree is used to solve the efficiency increase. Reference: http://blog.csdn.net/cpcpcp123/article/details/52744331 Two methods commonly used to solve the conflict are: open addressing and link address law
Open addressing: When a conflict occurs, a profiling (detection) sequence is formed in the hash table using some sort of probing (also called probing) technique.finds the specified keyword along this sequence, either until a given key is found, or when an open address (that is, the address cell is empty) (to insert, in the case of an open address, the new node to be inserted is stored in the Address cell). Probing to open addresses while searching indicates that there are no unknown origin keywords in the table, that is, the lookup failed. Link Address method:link all keywords to synonyms in the same single-linked list. If the hash list length selected is M, the hash list can be defined as an array of pointers consisting of M head pointers T[0..m-1]. All nodes with hash address I are inserted into a single linked list with T[i] as the head pointer. The initial value of each component in T should be a null pointer. 5. Answer: B The class name declared as public type must be the same as the file name, the default permissions can be different and the class name of the inner class is usually different from the file name. There can be multiple classes in a file, and if there is no public class, it can be the same as any class name. If there is a public class, the file name must be the same as this class name because there can be only one public class in a file. If there is only one class in the file, the filename must be the same as the class name 6,
Ceil: An integer greater than or equal to x and closest to it. Floor: The integer that is less than or equal to x and closest to X.
7.
When an object is assigned a value, such as a=b, it simply points the address of a object to the address of the B object, so there is only one 8, the answer A:A: The formal parameter can be considered as local variable. A formal parameter cannot leave a method like a local variable. Only works within methods, and is only used in methods, and is not visible outside the method. B: For formal arguments you can only use the final modifier, and any other modifier will cause a compiler error. However, with this modifier there is also a certain limitation, that is, the method can not make any changes to the parameters. In general, however, the formal parameters of a method do not have to be final decorated. Only in exceptional cases, that is: the method inner class. Inner class within a method if the parameter or local variable of this method is used, the parameter or local variable should be final. C: The value of the formal parameter is changed by the caller at the time of invocation, and the argument changes the value of the parameter with its own value (pointers, references are in this column), that is, the actual argument is passed. D: The parameter list of the method specifies what information to pass to the method, using the form of the object. Therefore, you must specify the type and name of each passed object in the argument list. Like anything in Java that passes an object, it is actually a reference, and the referenced type must be correct. --"Thinking in JAVA"
A
The formal parameter is the parameter that is set when the function is defined. For example function Head int min (int x,int y,int z) x, y, Z are the formal parameters. The actual arguments are the actual arguments that are used when the function is called.
C: Real argument D: a formal parameter can be an object and a reference to an object when it is passed. B: For formal arguments you can only use the final modifier, and any other modifier will cause a compiler error. However, with this modifier there is also a certain limitation, that is, the method can not make any changes to the parameters. In general, however, the formal parameters of a method do not have to be final decorated. Only in exceptional cases, that is: the method inner class.
Inner class within a method if the parameter or local variable of this method is used, the parameter or local variable should be final.
9.
Answer: B a,copyonwritearraylist for writing less read more concurrent scenes b,readwritelock that is read-write lock, he requires the write and write mutually exclusive, between the read and write mutually exclusive, between reading and reading can be executed concurrently. In the case of read and write less can improve efficiency c,concurrenthashmap is synchronous hashmap, read and write are locked d,volatile only ensure the visibility of multi-threaded operation, not guaranteed atomicity
10.
It's been injected into the factory.
<!--configuration transaction Manager-<property name= "TransactionManager" ><!--Configure transaction Properties--<property name= "Tran Sactionattributes "> <props>Declarative TransactionsManagement is built on the AOP. The essence is to intercept the method before and after it, and then create or join a transaction before the target method starts, committing or rolling back the transaction according to execution after the target method is executed. The greatest advantage of declarative transactions is that you do not need to programmatically manage transactions, so that you do not need to doping transaction-managed code in your business logic code, just make relevant transaction rule declarations in the configuration file (or through @transactional annotations). You can apply transaction rules to the business logic.
11.
The control expression after the Dswitch statement can only beShort , char, int, longInteger type and enum type, cannot befloat,double and BooleanType.String type is Java7 start support。
Java Exercise Exercises