Java Software Senior Engineer Pen Test
"Intellectual part"(30 points)
1. Burn an uneven rope for one hours, how to use it to judge half an hour? (5 points)
Burn at both ends
2.4,4,10,10, subtraction, how come 24? Four digits can only be used once (5 points)
(10*10-4)/4
3. If you have an infinite number of water, a 3L and 5L bucket, how do you accurately weigh 4L of water? (5 points)
The first step: put two times 3L water into the 5L pass, then 3L bucket left 1L water.
Step two: Pour the 1L water in the 3L bucket into a 5L bucket, when the 5L bucket has 1L water.
The third step: 3L bucket filled with water all poured into 5L buckets, 4L of water is called out.
4. A snail from the bottom of the climb to the wellhead, every day snail to sleep, evening only out of activity, a snail can climb 3 feet in the night, but during the day to sleep will go down 2 feet, well deep 10 feet, ask the snail can climb out a few days? (5 points)
8 days.
The first seven days are (3-1) *7 =7
The eighth night climbed 3 feet again, at this time has reached the wellhead. In the wellhead sleep want to slip also can't slip down.
5. There is a bacterium, divided by one minute into 2, another minute, divided into 4, so that a bacterium placed in a bottle, one hours after the bottle is filled with bacteria. Now imagine how long it will take to fill the bottle if it starts with two bacteria in the bottle. (10 points)
59 minutes.
A bottle of bacteria had been split for a minute, and there were two of them. The second bottle directly has two germs, which is the equivalent of adjusting the first bottle in the first minute. The situation in the future is exactly the same, so it's 59 minutes.
"Professional section"(70 points)
1. Briefly describe the object-oriented features and illustrate your understanding of the object opposite to you? (5 points)
Object-oriented is based on all things are objects of the philosophical point of view, a land of the abstract into a class, specifically you. The static and dynamic characteristics of an object are abstracted into properties and methods, that is, the algorithm and data structure of a kind of transaction are encapsulated in a class, and the program is composed of multiple objects and communication among each other.
Object-oriented has encapsulation, inheritance, polymorphism. The package concealed the details of the object without the need for a burst, the internal details of the change with the outside world, relying only on the interface to communicate. Encapsulation reduces the complexity of programming. Inheritance makes it easy to create a new class, and a class gives the compiler the tedious task of getting its non-private methods and common properties from derived classes. The inheritance and implementation of the interface and runtime type calibration mechanism produced by the polymorphic, so that different classes produced by the object can be the same message to make different responses, remember to improve the universality of the code.
In short, object-oriented features improve the reusability and maintainability of large programs.
2. What are the differences between ArrayList and Hsahset, the difference between HashMap and Hashtable? (5 points)
The difference between ArrayList and HashSet:
ArrayList is a set of ordered collections that hold references to objects, not the object itself. The objects that are stored can be duplicated.
HashSet objects that are stored are non-repeatable.
The difference between HashMap and Hashtable:
- Inheriting classes are different
- Hashtable is thread-safe, and HashMap is non-thread safe.
- The key,value of HashMap is allowed NULL, and Hashtable is not allowed. And the HashMap efficiency is high.
3. What are the key words for thread synchronization? What is the difference between sleep () and wait ()? How do I wake the Wait () stop thread? (5 points)
Thread Sync Keyword: synchronized
The difference between Sleep () and Wait ():
- Parent class different sleep () from the thread class, wait () from the Objcet class
- The main thing is that the sleep () method does not release the lock, and the wait method frees it so that other threads can use the synchronous null value fast or method.
Sleep does not yield system resources; Wait is the thread waiting for the pool to wait, let the system resources out, other threads can consume the CPU, and need notify,notifyalll to wake up the threads in the waiting pool.
- Use range: Wait,notify and notifyall can only be used in synchronous null method or synchronous control block, and sleep can be used anywhere
- Sleep must catch exceptions, while wait,notify and notifyall do not need to catch exceptions
4. List the design patterns (Pseudocode or class diagrams) that you use in your project, and describe the specific scenarios for each design pattern. (5 points)
Single-Case mode
public class singleton{
private static volatile Singleton Singleton = null;
Private Singleton () {}
public static Singleton Getsingleton () {
if (singleton = = null) {
Synchronized (Singleton.class) {
if (singleton = = null) {
Singleton = new Singleton ();
}
}
}
return singleton;
}
}
Multiple threads get an instance of an object multiple times without having to go to new every time.
4. What are the ways in which transaction management is supported in spring and how each method is used? (5 points)
Two ways to implement:
Coding method;
Declarative transaction management methods.
Declarative transaction management is implemented through AOP technology, in essence: interception before and after the execution of the method, and then creating and joining the transaction before the target method starts, and executing the completion target method and rolling back the transaction according to the execution situation.
There are two ways of declarative transaction management: Based on XML configuration file (Interceptor AOP), @transaction annotations via tags
Another answer:
1. Each bead has a transaction agent
- Hibernate cache level and its characteristics (5 points)
First-level cache: Session-level caching, when the session is closed, the cache is gone
Second-level cache: Sessionfactory cache, which caches objects
Query caching: The query cache is also a sessionfactory level cache, which caches SQL statements
The general level two cache is used in conjunction with the query cache to avoid n+1 problems. It is also recommended to use mamcatched to do a separate cache.
5. Write a regular expression of at least one 11-digit mobile number. (5 points)
^[1][358][0-9]{9}$
6. Implement the string "s tr in G" to "s tr in G" Conversion with a short code. Convert multiple spaces to a space (5 points)
String s = "s tr in G";
S=s.replaceall ("+", "");
7. Using the socket to write a program, the client sends a request to the server side (to send a string), the service side to send feedback information. (10 points)
TCP protocol
Online examples many find themselves. Code too long
8. Implement Oracle paging queries with SQL statements. (10 points)
SELECT * FROM (select ROWNUM rn,t.* from TableName t where T.rn <=40) TT where Tt.rn >=10
Select * from TableName where UserID limit 0, 20;
- AA,BB table has 20 fields, and the number of records is very large, AA,BB table x field (non-empty) on the index, please use SQL to list the AA table in the presence of x in the BB table does not exist in the value of x, please write the fastest statement, and interpret the reason. (10 points)
Select a.x from AA a where NOT exists (select 1 from bb b where a.x = b.x)
Java Advanced software engineer face questions