The Java software interview in Hangzhou

Source: Internet
Author: User
Tags aop finally block serialization

Two weeks, the interview of nearly 20 software companies in Hangzhou, sometimes under the popular Internet industry, there are traditional industries. Involved in many industries, social broadcasting platform, security monitoring, consumer credit, big Data wind control, Internet Medical, e-commerce and so on. Here write your own interview process encountered in the face of the test, to reflect on the lack of their own interview.

The IOC and AOP principles of the 1.Spring framework;

IOC: in the traditional implementation of the program, the code to control the relationship between the components, using the new keyword to achieve a combination of two components, which will bring the coupling between the objects, like a gear rotation, with the IOC, it will implement the component relationship from the internal like external transfer, The dependencies are injected into the component by the container during the run. A dynamically generated object based on the class name, which can be programmed to determine exactly which object it is when the object is generated.

AOP: by wrapping facets in a proxy object, weaving slices into container-managed beans during run time, the proxy class encapsulates the target class, intercepts calls to the notified method, and forwards the call to the true target bean. When a method call is intercepted, the agent executes the tangent logic before invoking the target bean. AOP provides two ways to generate proxy objects: Jdkproxy and Cglib, which are determined by aopproxyfactory based on the configuration of the Advisedsupport object. The default policy is to use the JDK dynamic proxy request if the target class is an interface, otherwise use Cglib to proxy.

2. Class loading mechanism

When the class file is loaded by the loader, a description of the class structure meta-information object is formed in the JVM, through which you can learn the structure information of class, such as constructors, properties, and methods.

Parent delegation Model:

If a class loader receives a class load request, it first delegates the request to the parent ClassLoader to complete, so all load requests should be routed to the top-level startup ClassLoader, and the child loader will attempt to load itself only if the parent loader feedback itself cannot complete the load request.

Loading:

    • Gets the binary byte stream of this class through the fully qualified name of a class;
    • The static storage structure represented by this byte stream is transformed into the data structure of the method area runtime;
    • Generate a Java.lang.Class representing this class in the Java heap as the gateway to the data in the method area;

Verify:

    • File Format verification: the input byte stream is guaranteed to be correctly parsed and stored in the method area;
    • Metadata validation: Verify the analysis of each data type in the class;
    • The method of verifying the method of the verified class will not make the behavior that endangers the virtual machine security in the operation;
    • Symbol Reference validation: matching checks for various symbol references in a constant pool;

Get ready:

Allocate memory for the class variable, and set the variable initial value, the memory will be allocated in the method area;

Analytical:

A virtual machine replaces a symbolic reference in a constant pool with a direct reference procedure

3. Distributed Transactions

Two-phase commit and message + final consistency based on XA protocol

4. Common Design Patterns

Single example, factory, adapter, responsibility chain, façade, decoration, strategy, observer, etc. say a few, and know the implementation method and application scenario.

5.sql Tuning

    • Try to avoid using query blur matching, which results in index invalidation. Like '%param% '
    • Avoid calculations on indexed fields, use not/<>/!= on indexed fields, avoid isnull/isnotnull on indexed fields, and do not use functions or null values on indexes;
    • Nested subqueries can consider using temporary tables
    • Union ALL can solve the scenario do not use union
    • Avoid the presence of in/not in the where statement in/having
    • Do not declare numbers in character format
    • Select statement to identify the field to query, do not always select *!!

6. Sub-database sub-table strategy

    • Intermediate variable =user_id% (number of sub-Libraries * per table quantity)
    • Library = rounding (intermediate variable/number of tables per library)
    • Table = middle variable% per library table number

[email protected] and @autowired difference

Same as: All do bean injection use

XOR: @AutoWired By default assembly objects by type Bytype, dependent objects must exist, and if null values are allowed, the required property can be set to false. @Resource by default in accordance with ByName injection, provided by the Java EE;

8.java7 new features, java8 new features

9.servlet life cycle

Initialize Phase Call Init method

Invoking the service method in response to a customer request

Terminate phase Call Destory method

10. Reasons for Slow page loading

Reduce the number of requests, reduce the size of resources, find the fastest server three aspects to optimize.

Optimize the format and size of image resources;

Turn on network compression;

use browser caching;

Less redirection, each redirect will cause the browser to reload the request, extending the load time;

Using CDN to cache static resources

Reduce DNS resolution times

Compress JS and CSS to remove spaces, etc.

11.set Bottom-level implementation

Key cannot be duplicated using the map

12.JVM Generational garbage collection

The Eden Zone is used to create a new object, to trigger a young GC at full time, to copy the objects that are still being used to the from area, the Eden area again runs out again, and then fires one more time, to copy the objects that are still in use in the Eden and from areas to the to area, and the next young The GC is a copy of objects that are also used by the Eden and to extents to the from zone, where the threshold object has not been released and copied to the old generation. Old runs out of trigger full GC. Set young generation and old generation to avoid generating full GC.

13. Load Balancing algorithm

Polling, weighted polling, random, least connection, source address hash.

14. High-Availability Architecture design

Primary means: Redundant backup and failover of data and services

15. Highly Available services

Tiered Management , core applications and services prioritize better hardware

Timeout setting , once timed out, the communication framework throws an exception, the app can select retry and request transfer

asynchronous invocation , in which the consumer takes the message queue

Service demotion , denial of service, and shutdown of services to ensure that core applications and functions are functioning properly

idempotent design to ensure that service invocation is the same as the result of multiple times;

16. Reflection mechanism

17. Distributed Cache consistency Hash (NetEase)

18.https principle (NetEase)

19. Optimistic lock and Pessimistic lock (NetEase)

20. Database Isolation Level

21.spring Transaction Propagation Properties

22.301 and 302 differences (NetEase)

301 Permanent Transfer 302 temporary transfer

23.get and Post differences

24. Table-Built Index rules

Avoid indexing large data types

Often use the index of group by and order by

To index the columns used for the connection

Indexes that are frequently present in the WHERE clause

Determine whether the table is a large number of queries or additions and deletions

25. There are several ways to cross a domain (NetEase)

26.HashMap and Concurrenthashmap

27. How is distributed lock implemented?

What are the advantages of 28.KAFKA technology and how is it implemented?

Three handshake with 29.TCP/IP protocol and four waves

30. How do I communicate between threads? NetEase

Synchronization (synchronized) such as thread A and thread B both hold an object, and thread B needs to wait until a executes before it can run. A and B implement communication, essentially shared memory communication, multiple threads need to access the same shared variable, who took the lock can be executed first

wait/notify mechanism , a calls wait to enter the block, when the condition is met, B calls notify Wake a

Pipeline communication is using PipedInputStream and PipedOutputStream to communicate

How does 31.spring handle cyclic dependencies?

Constructor Cyclic dependency:

<bean id= "A" class= "Com.donsun.student.StudentA" >  2     <constructor-arg index= "0" ref= "B" ></ Constructor-arg>  3 </bean>  4 <bean id= "B" class= "Com.donsun.student.StudentB" >5     < Constructor-arg index= "0" ref= "C" ></constructor-arg>  6 </bean>  7 <bean id= "C" class= " Com.donsun.student.StudentC ">8     <constructor-arg index=" 0 "ref=" A "></constructor-arg>  9 </bean>

The spring container places each bean identifier being created in a "currently created Bean Pool", which is kept in the pool during creation, so if you find yourself in the "Currently creating bean pool" during the creation of the bean The beancurrentlyincreationexception exception is thrown to indicate a cyclic dependency, and the created Bean is purged from the currently created Bean pool.

Setter cyclic Dependency (singleton):

<!--scope= "singleton" (default is A single case)  -   2 <bean id= "A" class= "Com.donsun.student.StudentA" scope= " Singleton "> 3     <property name=" Studentb "ref=" B "></property>   4 </bean>   5 <bean ID = "B" class= "Com.donsun.student.StudentB" scope= "singleton" > 6     <property name= "STUDENTC" ref= "C" ></ property>   7 </bean>   8 <bean id= "C" class= "Com.donsun.student.StudentC" scope= "Singleton" > 9     <property name= "Studenta" ref= "A" ></property>  </bean>

In this case, spring instantiates the Bean object first, and spring places the instantiated object into a map, and spring provides a way to get the instantiated object reference for this property that is not set. When spring instantiates Studenta, STUDENTB, STUDENTC, and then goes to set the properties of the object, the Studenta depends on the STUDENTB, it will go to the map to remove the existence of the singleton Studentb object, and so on, The problem of not coming out of circulation;

Here's how the spring source is implemented. The following source code is in the Defaultsingletonbeanregistry.java class in spring's Bean package

 1/** Cache of Singleton Objects:bean name-to-bean instance (a collection of maps of the instance instantiation object) */2 private final Map<strin   G, object> singletonobjects = new concurrenthashmap<string, object> (64); 3 4/** cache of Singleton Factories:bean name--objectfactory (Singleton factory Bean Cache Collection) */5 Private final Ma   p<string, objectfactory> singletonfactories = new hashmap<string, objectfactory> (16); 6 7/** cache of early singleton Objects:bean name--bean instance (early single object cache collection) */8 private final   map<string, object> earlysingletonobjects = new hashmap<string, object> (16);     9/** set of registered singletons, containing the bean names in Registration order (a collection of instantiated object names in Singleton) */11  Private final set<string> registeredsingletons = new linkedhashset<string> (64); 12/** 13 * Add a singleton instance 14 * Fix a problem with circular references * Add the given singleton factory for building the specified Singl Eton * If neceSsary. <p>to is called for eager registration of singletons, e.g. to being able to * resolve circular refere NCEs.      * @param beanname The name of the bean * @param singletonfactory the factory for the singleton object 21 * * protected void Addsingletonfactory (String beanname, objectfactory singletonfactory) {assert.no  Tnull (Singletonfactory, "Singleton factory must not being null");                 Synchronized (this.singletonobjects) {(!this.singletonobjects.containskey (beanname)) {26  This.singletonFactories.put (Beanname, singletonfactory);  This.earlySingletonObjects.remove (Beanname);  This.registeredSingletons.add (Beanname); 29} 30} 31}

Setter cyclic Dependency (prototype):

2 <bean id= "A" class= "Com.donsun.student.StudentA" scope= "Prototype" > 3     <property name= "Studentb" ref= "B "></property>   4 </bean>   5 <bean id=" B "class=" Com.donsun.student.StudentB "scope=" Prototype "> 6     <property name=" STUDENTC "ref=" C "></property>   7 </bean>   8 <bean ID = "C" class= "Com.donsun.student.StudentC" scope= "prototype" > 9     <property name= "Studenta" ref= "A" ></ Property>  </bean>

Because the bean,spring container of the "prototype" scope is not cached, it is not possible to expose a created bean in advance. Throw Beancurrentlyincreationexception

32.try{}catch () {}finally{}return Various change return values

1, whether there is no exception, finally block code will be executed;
2, when there is return in the try and catch, finally will still execute;
3. Finally is executed after the return of the expression after the operation (at this time does not return the value of the operation, but the first to save the value to return, regardless of the code in the Finally, the return value will not change, is still the previous saved value), So the function return value is determined before the finally execution;
4, finally, it is best not to include return, or the program will exit early, the return value is not a try or catch in the saved return value.

33.redis Recycling Strategy

34. Collection Iteration Efficiency comparison

The difference between 35.ArrayList and LinkedList

36.JVM memory model

37.java Serialization algorithm

38. Red and black Trees

39.synchronized use of the scene

40. Thread pool configuration key parameters

41. What frames are used in peacetime, and what source code is seen and how it is implemented

42. Draw the architecture diagram of the project you have done

43. Breadth-first traversal and depth-first traversal

44. What do you think you are best at?
45. How does the project change to distributed?

46.HashMap has an object transient entry[] table, why add keyword transient?

1. Take a look at Hashmap.get ()/put () know that read-write map is based on Object.hashcode () to determine from which bucket read/write. and Object.hashcode () is a native method, different JVMs may not be the same , if you use the default serialization, then after deserialization, the position of the element and the previous is consistent, but because the value of hashcode is different, then the positioning function indexOf () The element returned by the subscript will differ, this is not the result we want.

2.transient is to indicate that the data is not involved in serialization. Because there is a lot of space in the array data members of the HASHMAP that are stored in the data is not used, the space that is not used is serialized without meaning. So you need to manually use the WriteObject () method to serialize only the array of actual stored elements.

47. Distributed lock Usage scenario (NetEase)

48.dubbo version number function (NetEase)

When an interface is implemented, when an incompatible upgrade occurs, the version number can be used to transition, and the service of different version number to each other
Not referenced.
In a low-pressure time period, upgrade half the provider to the new version first
Then upgrade all consumers to the new version
Then upgrade the remaining half of the providers to the new version

49. Second-kill system design (NetEase)

50. Differences between inner classes and nested classes

51. Algorithm: Recursive implementation palindrome (NetEase)

52. Algorithm: The program implements the string has the English letter space number, cannot use the ASCII code to judge

53.zookeeper distributed lock node differs from other nodes (NetEase)

Persistent Persistence node PERSISTENT_SEQUENTIAL 顺序自动编号持久化节点,这种节点会根据当前已存在的节点数自动加 1Ephemeral temporary node, the client session timeout such nodes will be automatically deletedephemeral_sequential Temporary Auto-numbering node

54. What are the problems encountered in the project and how to resolve them?

55.SPRINGMVC complete workflow, what are the key classes

Examples of design patterns used in 56.spring

57. Deadlock Conditions

Lesson:

1. Make a resume in accordance with the Star rules;

2. Different company positions need to be different, resume should be targeted, do not only prepare a resume;

3. In accordance with the requirements of the job, in the project to highlight the matching skills, first through the screening of this;

4. To be ready to vote resume, or your favorite company let you go to the interview, the result you did not how to prepare, was brushed, then the opportunity may not have!

5. The technology listed in the project, can not stay on the surface of the understanding, at least you can go in your own heart, or your resume in the interviewer is not the sheep into the tiger!

6. Internet companies are more concerned about distributed, middleware, concurrent programming, locks and the like, it is recommended to learn more about the Java and the contract and the market popular middleware;

The Java software interview in Hangzhou

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.