Java Interview Summary (all personal interview experience)

Source: Internet
Author: User
Tags one table

First, how to compare two objects, such as student class, according to the age of the attribute comparison size

Not yet, who would ask for guidance

Two, give you a set how to sort objects according to the name of the student class


Three, give you a server, want you to install Tomcat, what you have to do

Install on Linux: After the upload installation package decompression, configure Tomcat7\conf\tomcat-users.xml, at the bottom of the file,</tomcat-users> add

<role rolename= "Manager-gui"/><role rolename= "Manager-script"/><role rolename= "manager"/>< Role rolename= "Admin-gui"/><user username= "admin" password= "admin" roles= "manager-gui,manager,manager-script , Admin-gui "/>


Iv. How to take the key in the map

Two methods Map of Map.keyset (); and Map.entryset (); Method

Test code:

Package Com.lyt.test;import Java.util.collection;import Java.util.hashmap;import java.util.iterator;import Java.util.map;import Java.util.set;public class Maptest {public static void main (string[] args) {getkeyset (); Getentryset ();} Get public static void Getkeyset () {System.out.println ("--------keySet () method get-------------") according to the KeySet () method in map;    Map map = new HashMap ();    Map.put (1, "a");    Map.put (2, "B");    System.out.println (Map.keyset ());    Collection s = map.keyset ();    System.out.println (s);    Iterator iter2 = (Iterator) map.keyset (). Iterator ();    while (Iter2.hasnext ()) {System.out.print (Iter2.next () + ",");    } System.out.println ("======== Gets the value of method ========");    Collection C = map.values ();    System.out.println (c);    Iterator iter1 = (Iterator) map.values (). Iterator (); while (Iter1.hasnext ()) {System.out.print (Iter1.next () + ",");//one to get value values}}//get public stat based on the EntrySet () method in map IC void Getentryset () {System.out.println ("--------entryset () method gets-------------");    Map map = new HashMap ();    Map.put (1, "a");    Map.put (2, "B");    System.out.println (Map.entryset ());    Collection s = map.entryset ();    System.out.println (s);    Iterator iter2 = (Iterator) map.entryset (). Iterator ();    while (Iter2.hasnext ()) {System.out.print (Iter2.next () + ","); }}}


V. HashMap how to store data

HashMap is essentially a combination of arrays and linked lists, remember that the C data structure of version Min is called "Hash list". For HashMap storage, you can understand that arrays are used to store keys, that lists are used to store value, and that each linked list is linked to an element in an array.

ArrayList is essentially a sequential dynamic array, starting with a default value open an array, full after the expansion, and implemented dynamic additions and deletions.

Performance differences: Hashmpa is used for quick lookups, but ArrayList basically does not waste space. Each has its pros and cons.

View Details: http://blog.csdn.net/vking_wang/article/details/14166593

Six, is not using MAVEN, there is a module on the project, you know why to divide it? (This can't be said to think about it)


1. What business scenario do we use recursive notation, please give an example and explain

2, Dubbo, WebService or you are familiar with the interface and the difference between the HTTP interface? What should we pay attention to when we do these interface interactions?

What is the difference between WebService interface and HTTP interface: protocol is different



3, why do we use the serial number and the anti-serial number in the development, you know which serialization tools, and describe their advantages and disadvantages

Serialization is a mechanism for dealing with the flow of objects, so-called object flow is the flow of the object's contents. It is possible to read and write to a Fluidized object, or to transfer the streamed object between the networks. Serialization is a problem that can arise when the object stream reads and writes (if there is no serialization, there may be a problem with data scrambling). To serialize, you need to have a class implement the Serializable interface, which is an identifying interface that annotations the class object can be serialized, and then uses an output stream to construct an object output stream and pass WriteObject (object obj) Method can write out the implementation object (that is, save its state), or, if deserialization is required, you can create an object input stream with an input stream and then read the object from the stream through the ReadObject method. Serialization can be used for deep cloning of objects in addition to the persistence of objects

4. Enumerate the difference between relational database and non-relational database? For the current NOSQ database talk about its application scenarios and advantages

5, briefly describe the difference between hibernate and MyBatis, which one you prefer to use, why?

See also: http://blog.csdn.net/liyintaoliuyun/article/details/51446758

6, we in the use of SPRINGMVC development, is how to encapsulate the data and calibration, for the restful transmission style whether to understand, say its characteristics

7. Describe the transaction characteristics of spring? What business scenarios need to use transaction control


8. Why should Java have garbage collection? When does it take place? How to detect a memory leak

GC is the meaning of garbage collection, memory processing is a problem for programmers, forget or wrong memory recycling will cause the program or system instability or even crash, Java provides the GC function can automatically monitor whether the object exceeds the scope to achieve the purpose of automatic recovery of memory, The Java language does not provide a display action method that frees allocated memory. Java programmers don't have to worry about memory management because the garbage collector is automatically managed. To request garbage collection, you can call one of the following methods: System.GC () or Runtime.getruntime (). GC (), but the JVM can mask the displayed garbage collection calls.

Garbage collection can effectively prevent memory leaks and effectively use memory that can be used. The garbage collector is typically run as a separate, low-priority thread, and in unpredictable cases the dead or unused objects in the heap are purged and reclaimed, and the programmer is not able to call the garbage collector in real time for garbage collection of an object or all objects. In the early days of Java, garbage collection is one of the biggest highlights of Java, because the server-side programming needs to effectively prevent memory leaks, however, now the Java garbage collection mechanism has become the thing to be criticized. Mobile Smart end users often feel that iOS systems have a better user experience than Android systems, and one of the underlying reasons is the unpredictability of garbage collection in the Android system.

Add: There are many kinds of garbage collection mechanisms, including: Generational replication garbage collection, token garbage collection, incremental garbage collection, and so on. The standard Java process is both stack and heap. The stack holds the original local variables, and the heap holds the objects to be created. The basic Java platform algorithm for heap memory recycling and reuse is known as tagging and purging, but Java has improved it with "generational garbage collection." This method divides the heap memory into different areas with the Java object's life cycle, and may move objects to different areas during garbage collection:

    • Eden: This is the area where the object was originally born, and for most objects, this is the only area where they exist.
    • Survivor's Paradise (Survivor): Objects that survived from Eden will be moved here.
    • Lifelong home Garden (tenured): This is the end of an old enough survivor. The Young Generation Collection (MINOR-GC) process is not going to touch this place. When the young generation collects objects that cannot be placed into a lifelong home garden, it triggers a full collection (MAJOR-GC), which may also involve compression in order to make enough space for large objects.

JVM parameters related to garbage collection:

    • -XMS/-XMX---The initial size of the heap/maximum size of the heap
    • -XMN---The size of the young generation in the heap
    • -XX:-DISABLEEXPLICITGC---let System.GC () not have any effect
    • -xx:+printgcdetail---print GC details
    • -xx:+printgcdatestamps---Print the timestamp of the GC operation



9, your company's projects have used those frameworks, all use the spring of those core, the project how to reflect the
Spring Reference http://blog.csdn.net/lovesomnus/article/details/46470255

10, how do you realize the distributed

11. What cache database have you used? Under what circumstances need to use

12. Do you have multiple threads in your project? Do you know how to implement multithreading? Why do you need multithreading in there?

There are two ways to implement multithreading before Java 5: One is to inherit the thread class, and the other is to implement the Runnable interface. Both methods define the behavior of the thread by overriding the run () method, which is recommended because inheritance in Java is a single inheritance, a class has a parent class, and if inheriting the thread class can no longer inherit other classes, it is obvious that the runnable interface is more flexible.

Add: Java 5 creates a thread later in the third way: Implement the callable interface, where the call method can produce a return value at the end of the thread execution, as shown in the code:

Package Com.lyt.test;import Java.util.arraylist;import Java.util.list;import java.util.concurrent.callable;import Java.util.concurrent.executorservice;import Java.util.concurrent.executors;import java.util.concurrent.Future;/* * * Implement callable interface, the call method in this interface can produce a return value at the end of thread execution * @author Administrator * */class MyTask implements Callable<integer > {private int upperbounds;public mytask (int upperbounds) {this.upperbounds = Upperbounds;} @Overridepublic Integer Call () throws Exception {int sum = 0;for (int i = 1; I <= upperbounds; i++) {sum + = i;} return sum;}} public class Test {public static void main (string[] args) throws Exception {list<future<integer>> List = new A Rraylist<> (); Executorservice service = executors.newfixedthreadpool (int i = 0; i <; i++) {List.add (Service.submit (New My Task ((int) (Math.random () * 100))));} int sum = 0;for (future<integer> future:list) {while (!future.isdone ()); sum + = Future.get ();} System.out.println ("return value:" + sum);}} 



13. Do you know the message queue?

14. How large is your project business? If the amount of data in a table is getting larger and slower, the query will be more and more slow, how would you handle

When writing SQL, pay attention to optimization without so many joins, do partition indexing

Here are two simple examples:

Library Example: a library so many books, how to manage it? Create a directory with the beginning of a letter, for example: A book, in the first row, B starts in the second row, so in search of what book to say, this is a clustered index, but a lot of people borrow books to find a writer, do not know the title how to do? The librarian is writing a table of contents, the books of a certain author in the first row, the first few rows, this is a nonclustered index

Dictionary example: the dictionary in front of the directory, you can follow the pinyin and radicals to query, we want to query a word, just according to pinyin or radical to query, you can quickly locate the Chinese character, this is the benefit of the index, pinyin query method is a clustered index, the radical query is a nonclustered index.

Looking at the above example, the following sentence is easy to understand: Clustered index storage records are physically contiguous, while nonclustered indexes are logically contiguous, and physical storage is not contiguous. Just like a field, a clustered index is contiguous, A is definitely B, a nonclustered index is not contiguous, like a library author's book, possibly on the 1th shelf and the 10th shelf. There is also a small knowledge point is: A clustered index can only have one table, and a non-clustered index a table may exist more than one.


There are two types of SQL indexes, clustered and nonclustered, and indexes are primarily designed to improve the performance of SQL Server systems, speed up data queries and reduce system response time
Syntax for creating indexes:

CREATE [unique][clustered | Nonclustered] INDEX index_name

on {table_name | view_name} [WITH [Index_property [,.... N]]

Description

Unique: Create a unique index.

CLUSTERED: build a clustered index.

Nonclustered: builds a nonclustered index.

Index_property: indexed properties.

A UNIQUE index can take either a clustered index structure or a nonclustered index structure, and the SQL Server system defaults to a nonclustered index structure if the index structure is not specified.

To delete an index syntax:

DROP INDEX Table_name.index_name[,table_name.index_name]

Description:table_name: The name of the table where the index resides.

Index_name: The name of the index to remove.

Use system stored procedure:sp_helpindex to view the index information for the specified table.

The execution code is as follows:

Exec sp_helpindex Book1;



15, in the project may encounter this situation, the company will be out of the report, but the background business is still running, which will cause the report query will be deadlocked, you have any good solution?

Do the background business method and the method of the report to do thread synchronization

or the background business process to give a sign and then can be out of the report (to do a good job of labeling a better personal recommendation)

16, an Account table has n accounts, each account in the accounting process will be the operation of different accounting procedures for the balance update, how do you avoid data inconsistency and deadlock?

How to add a lock on a balance update

17, you know the restful bar, can you say it? What's the difference between it and webservice?

Protocol is different,

If the data type is more complex, use WebService

18. Do you know Linux? If you want to change a file, how do you change it?

VIM filename. xml and so on after the file is executed go in then I can operate,: QW Save and exit
Reference: http://blog.csdn.net/liyintaoliuyun/article/details/51407006

19. What is the verification of the request in your project?

Java Interview Summary (all personal interview experience)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.