Interview Summary--java senior Engineer (ii)

Source: Internet
Author: User
Tags message queue new set serialization volatile mysql index redis cluster

first, the Java underlying basic problem

1, the principle of SPRINGMVC and how to render the return data to jsp/html?

A: The core of Spring MVC is dispatcherservlet, a request passed through Dispatcherservlet, forwarded to handlermapping, then reflected, corresponding  The @requestmapping address of the controller and the methods inside it, and the final return to the corresponding view via Modelandview and Viewresoler. For specific reference: how Spring MVC Works

2. How do I let the caller know when a Class object property has changed?

A: Java event time monitoring, which is triggered when the Set method changes properties, this mode can also be understood as the observer pattern, specific view: Observer pattern simple case and Description

3. Rewrite equals why do you want to rewrite hashcode?

A: To determine whether two objects are equal, the comparison is its hashcode, if you overload the Equals, for example, based on the content of the object implementation, while preserving the hashcode implementation is not changed, it is likely that the two objects are obviously "equal", and hashcode is not the same. Hashcode is not the same, you cannot assume that two objects are equal

4. What about your understanding of the JVM?

A: a very important feature of the Java language is its independence from the platform. The use of Java virtual machines is the key to achieving this feature. The Java compiler generates code or bytecode files that the JVM can understand as long as it is oriented to the JVM. The Java source file is compiled into a bytecode program that translates each instruction into a different platform machine code through the JVM, running through a specific platform.

The process by which the JVM executes the program: I. Load. class file, II. Managing and allocating memory, Iii. performing garbage collection

JRE (Java Runtime Environment) the running environment of Java programs constructed by the JVM

Specific details: JVM Principle and tuning

5. What is the level of the MySQL thing isolation?

A: MySQL thing isolation level is actually the same as spring's thing isolation level, are 1, read UNCOMMITTED (reading uncommitted content), 2, read Committed (read the submission), 3, repeatable read (can reread), 4, Serializable (serializable) Specific reference: MySQL thing isolation level

6. Spring principle

A: The core of spring is IOC and AOP, the IOC is dependency injection and control inversion, its injection method can be divided into set injection, constructor injection, interface injection and so on. The IOC is a container that is responsible for instantiating, locating, configuring objects in the application, and establishing dependencies between those objects. The simple understanding is that Java each business logic processing requires at least two or more objects to work together, but each object in the use of its co-object, the need for frequent new objects to implement, you will find that the coupling between objects is high. The IOC's idea is that the spring container manages these, and the object only needs to deal with its own business relationship. As for what is control reversal, it is the way to get dependent objects reversed.
AOP, aspect-oriented programming, the most direct manifestation is the spring things management. As for the relevant information of spring, we will not elaborate, reference: Spring Annotated Things management

7. Talk about your understanding of NIO

A: IO is a stream-oriented, NIO is buffer-oriented, here is not a detailed reference: the difference between Java NiO and IO

8, the difference between ArrayList and LinkedList, vector?

A: It must be understood as:.

1.ArrayList is the realization of the data structure based on dynamic array, LinkedList data structure based on linked list.
2. For random access get and set,arraylist feel better than LinkedList, because linkedlist to move the pointer.
3. Add and Remove,linedlist for new and delete operations are dominant because ArrayList is moving data

Vector and ArrayList similar, but belong to the strong synchronization class, that is, thread-safe, specific comparison reference: Compare ArrayList, LinkedList, Vector

9, casually talk about a few singleton mode, and choose a thread-safe

A: Singleton categories: lazy, a hungry man, enumeration, static internal class, double check lock and so on, select thread safety I chose the last, double-check lock. Specific implementation methods reference: Java: Seven Ways to make a single case pattern

10. Talk about red and black trees

Answer: The algorithm and data structure has been my weak point, this aspect said oneself fill, the effect is not big, here I recommend one: red black tree

11, for example to say a few sort, and explain its sorting principle

A: I'm not going to go into detail here, let's take a look at Java implementation of several common sorting algorithms

12. mysql Index principle

A: The role of the index everyone knows, is to speed up the query speed, but the principle, I can not say, here to see directly: MySQL index how it works

13. The principle and function of serialization

A: Serialization (serialization) is a process of describing objects in a sequence of bytes, and deserializing deserialization is a process of re-building these bytes into an object. It is mainly used for the propagation of object parameters during HTTP or WebService interface transmission, see: Java Serialization mechanism and principle

Second, concurrency and project tuning

1, say a few ways to realize the thread safety?

Answer: What is thread safety? My understanding is that an object that is accessed concurrently by multiple threads can maintain the order and synchronization of its internal properties, and is considered thread-safe.  Three ways to implement thread safety: be modified by keywords such as volatile, synchronized, or use the class library below Java.util.concurrent. As for the relationship between the former two, refer to:synchronized and volatile usage differences

2, how to achieve better asynchronous inside the method?

A: We know that async is actually getting another thread to run, so how do I create a thread? The first is the direct new Thread, and the second is the implementation class that implements the Runnable interface. Third, through the thread pool to manage the creation and so on, here is the better implementation of async, that is to say we avoid frequent new threads inside the method, we can consider the thread pool. So how does the thread pool create? You can create a new thread pool here, but you need to consider a singleton, or create a thread pool when the program is initially Qidong, let him run, and then, at the time of the method, creating threads by thread pool to implement asynchronous

3. Why should I use cache in the project? How do I understand Nginx + tomcat + redis cluster cache?
Answer 1:The most immediate performance is to reduce the pressure on the database. Avoid the possibility of a program outage due to frequent or oversized data reads that affect database performance
2:nginx often do static content services and proxy servers, facing the external request forwarded to the back of the application services. Nginx itself can also do cache, such as static page cache what. Tomcat is an application server that handles Java Web program functionality and so on. You can also understand that, assuming the user's request as a river, then Nginx is equivalent to a water conservancy project, Tomcat is equivalent to a diversion of tributaries, and Redis is equivalent to a single reservoir next to a branch. When you flood, Nginx distributes different amounts of water according to the strength of each tributary, distributing it to each tributary (Tomcat) in a way that ensures the program is running normally. And the Redis equivalent of a tributary of the reservoir, storage water, reduce pressure, so that the back of the water smooth.


4. In daily projects, if you take over, where are you going to tune in?
A: The first is to understand what needs to be optimized, the need for optimization must be the performance of the project bottleneck or speculation is imminent, we will consider optimization. So how to optimize?
A, expansion, expansion of the understanding of the expansion of the server parallel processing capacity, simply to add the server, increase the ability to process requests, such as increased nginx, Tomcat and other application server number, or the number of physical servers, as well as increase the server bandwidth, and so on, here is to consider the hardware
B. Tuning and tuning, including system tuning and code tuning. System tuning means faster processing speed, such as the CDN, Ehcache, Redis and other cache technology mentioned, message queue, etc., to speed up the response between services, increase system throughput, avoid concurrency, as for code tuning, these need to accumulate, such as refactoring, factories, etc. Database tuning I'm not quite sure of that. Index and stored procedures, specific reference: MySQL Database tuning 21 best practices, other database tuning aspects look for yourselves.

5. Talk about your understanding of distributed

A: Personal understanding: Distributed is to split a system/business into multiple subsystems/sub-business to work together, this process is called distributed, the specific evolution of the reference: Java Distributed Application Technology architecture Introduction

6. Redis implements Message Queuing

Answer: Redis implements Message Queuing, reference 2

7, Another summary of multi-threaded related questions 50 road

8. Share a tuning tool and solution: How to use Jconsole to observe and analyze the operation of Java programs, and to perform debugging and tuning

Previous Interview Summary: Face Test summary--java senior Engineer

Previous technical questions and answers: Technical questions and answers also mention some of the interview experience and knowledge points

Three, handwritten code questions (including SQL questions)

1, suppose merchant table A (ID, city), Trade flow table B (aid, amount, time) here time represents the trading hours, please write in SQL to query each city monthly sales performance (answer can be in the comments reply)

2. Suppose there is an array a, int[] a = {1, 3,-1, 0, 2, 1,-4, 2, 0, 1 ...   N}; It is necessary to find an array greater than 0, but due to the error of the parameters or other reasons, resulting in the detection of 0 and negative numbers, it is now required to not use the new array and the new set (that is, only use this a array, the factor group data is larger, and can only use one loop) to implement positive numbers in front of the array Numbers less than or equal to 0 are placed at the end of the array (answers can be answered in comments)

Summarize:

For the time being summarize these, follow up again, the face question is changeable, the invariable is the knowledge point and the technology fundamental. The foundation is very important, therefore does not accumulate kuibu, not to be thousands of miles, does not accumulate the small stream, does not have to become Jianghai. Learn the foundation, grasp the principle of good technology, and then to practice, so as to understand a technology, learning can not have!

In addition, the interview process, to maintain self-confidence, will not be bold to say no, no good disgrace, not to say you really will not, perhaps forget, perhaps did not notice, remember the interview topic, back to their own supplementary information and related information, I believe you will be more and more calmly, to remember not for the interview and interview, But for the future job interview, if can keep this state, there is nothing to take.

In my own case, many will not, the key is that you would like to learn, willing to put into action. Come on, I hope you crossing can find the right job.

Interview Summary--java senior Engineer (b)

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.