Interview questions that top programmers will encounter

Source: Internet
Author: User
Tags garbage collection hash memory usage redis serialization thread class volatile

The following excerpt from the top programmers encountered problems, the following will not be regularly published answers, there are know the answer can be written in the comments, of course, the answer does not ask for details as concise as possible, so that we can improve the success rate during the interview. Write the number directly for example 11: The answer is for everyone to progress together.

First, data structure and algorithm Foundation

1. Describe several common sorting algorithms and the complexity of the differences.
2. Write a bubble sorting algorithm in Java
3. Describe the chain-store structure.
4. How to traverse a binary tree.
5. Pour a linkedlist.
6. Write a recursive traversal of all files under the directory in Java.

Second, the Java Foundation

1. The difference between an interface and an abstract class.
What are the classes of exceptions in 2.Java? How to use them separately.
3. What are the common collection classes? such as how the list is sorted.
What is the implementation of 4.ArrayList and LinkedList inside? The difference between them and their pros and cons.
5. Memory overflow What's going on. Please give an example.
The difference between 6.== and equals.
The role of the 7.hashCode method.
What 8.NIO is. for which scenario.
9.HASHMAP implementation principle, how to ensure hashmap thread safety.
10.JVM memory structure, why GC is required.
11.NIO model, the difference of select/epoll, the principle of multiplexing
How many bytes of a character in 12.Java, extended ask int, long, double the number of bytes
13. There are ways to create an instance of a class.
The difference between 14.final/finally/finalize.
The difference between 15.session/cookie.
16.string/stringbuffer/stringbuilder the difference, the extension asks them again for their realization.
17.Servlet life cycle.
18. How to allocate a contiguous 1G of memory space in Java. What to pay attention to.
19.Java has its own memory-recycling mechanism, but why is there a memory leak problem?
20. What is Java serialization and how do I implement Java serialization? (Write an instance).
21.String s = new string ("abc"); several string Object created?

Third, the JVM

The basic structure of the 1.JVM heap.
What kinds of garbage algorithms do 2.JVM have? The basic process of CMS garbage collection.
3.JVM What common startup parameters can be adjusted to describe a few.
4. How to view the memory usage of the JVM.
5.Java program is memory overflow, memory leak occurs. Give a few examples.
6. What are your common JVM configuration and tuning parameters? respectively what effect.
7.JVM of memory structure.
8. Commonly used GC policies, when will trigger YGC, when to trigger FGC.

Iv. Multithreading/concurrency

1. How to create a thread. How to ensure thread safety.

In Java if you want to create a thread, there are generally two ways:
1) inherit the thread class; 2) Implement the Runnable interface.
How to ensure thread safety in Java.
Generally, there are several ways to ensure thread safety: competition and atomic manipulation, synchronization and locking, reentrant, over-optimization.
personally, to ensure thread safety, there is no way to maintain thread synchronization,
such as: @synchronized, Nslock, Dispatch_semaphore, Nscondition, Pthread_mutex, Osspinlock.
however:
Osspinlock and Dispatch_semaphore are much more efficient than others.
synchronized and Nsconditionlock are inefficient.
in view of Osspinlock's insecurity, we recommend using Dispatch_semaphore if we consider performance in development.
If you don't think about performance, just make it easy, then use synchronized.
2. How to implement a thread-safe data structure
3. How to avoid deadlocks
The role of the 4.Volatile keyword.
5.HashMap use in multi-threaded environments need to be aware of what. Why.
The 6.Java program starts a thread with run () or start ().
7. What is a daemon thread. What is the use of.
8. What is a deadlock. How to avoid
9. What are the differences between threads and processes?
How the Threadlocal is implemented in 10.Java.
The principle of 11.CONCURRENTHASHMAP implementation is.
12.sleep and wait differences
13.notify and Notifyall differences
14.volatile keyword
The function and realization of 15.ThreadLocal
16. How to perform serial execution of two threads
17. What does context switching mean
18. Can I kill a thread while running?
19. What are conditional locks, read and write locks, spin locks, and reentrant locks.
20. Thread pool Threadpoolexecutor implementation principle.

Five, Linux use and problem analysis troubleshooting

1. Create a file with two commands.
2. The difference between hard links and soft links.
What are the 3.Linux common commands?
4. How to see the resource consumption of a Java thread.
5.Load is too high a possibility of which.
6./etc/hosts file what to do with.
7. How to quickly replace all "ABC" in one text with "XYZ".
8. How to search the log file to find out the error logs.
9. Find the disk space is not enough, how to quickly find the most space-occupying files.
10.Java Server-side troubleshooting (OOM,CPU high, load high, class conflicts)
11.Java Common troubleshooting tools and usage (top, iostat, Vmstat, SAR, tcpdump, JVISUALVM, Jmap, Jconsole)
How to parse 12.Thread dump file (Runnable, lock, code stack, OS Thread ID Association)
13. How to view thread information for Java apps.

Vi. use of the framework

1. Describe the three states of Hibernate.
The life cycle of the bean in 2.Spring.
The process of 3.SpringMVC or struts processing requests.
What problems 4.Spring AOP solves. How it's achieved.
The propagation property of the 5.Spring transaction is going on. What it will affect.
What is the difference between beanfactory and Factorybean in 6.Spring?
What the IOC principle is in the 7.Spring framework.
What are the different ways of 8.spring dependency injection?
9.struts Work Flow
10. How to implement a facet with spring.
11.Spring How to implement database transactions.
12.Hibernate the use of one or two-level cache, lazy-load understanding;
13.mybatis How to implement bulk submissions.

Vii. database-related

Features of 1.MySQL InnoDB and Mysaim.
2. The difference between optimistic and pessimistic locks.
3. What is the database isolation level. Have any effect.
4.MySQL Primary and Standby synchronization fundamentals.
5.select * FROM table t where size > Ten group By size order by size SQL statement execution sequence.
6. How to optimize database performance (indexes, sub-library tables, bulk operations, paging algorithms, upgrading HDD SSD, business optimization, master-slave deployment)
7.SQL What case does not use index (not included, not equal, function)
8. What fields are generally indexed (the fields that filter the most data)
9. How to isolate all rows in the Name field that do not contain "XYZ" from a single table.
10.mysql,b+ index implementation, row lock implementation, SQL optimization
11.redis,rdb and AoF, how to do high availability, cluster
12. How to solve the problem of high concurrency reduction inventory
The implementation mechanism of index in 13.mysql storage engine;
14. Several granularity of database transaction;
15. Row lock, table lock, optimistic lock, pessimistic lock

VIII. Network protocols and network programming

1.TCP the process of establishing a connection.
2.TCP the process of disconnecting.
3. The logic behind the 302 jump in the browser occurs.
The interactive process of the 4.HTTP protocol. HTTP and HTTPS differences, SSL interaction process.
What is the relationship between 5.Rest and HTTP. Everyone says that rest is lightweight and how you understand the rest style.
What is the use of the 6.TCP Sliding window protocol? Talk about the principle.
What are the methods of the 7.HTTP protocol?
8. The difference between a switch and a router.
The basic flow of 9.Socket interaction.
10.HTTP protocol (message structure, breakpoint continuation, multi-threaded download, what is long connection)
11.TCP protocol (build connection process, slow start, sliding window, seven layer model)
12.webservice protocol (wsdl/soap format, difference from rest protocol)
13.NIO Benefits, Netty threading model, what is 0 copy

Nine, Redis and other cache systems/middleware/nosql/consistency hash, etc.

1. Enumerate the concurrency models for a common Redis client.
2.HBase How to implement fuzzy query.
3. List A common message middleware, if the message is to be ordered how to implement.
4. How to implement a hashtable. How your design considers hash collisions. How to optimize.
5. Distributed cache, consistent hash
6.LRU algorithm, slab allocation, how to reduce memory fragmentation
7. How to resolve cache stand-alone hotspot issues
8. What is the Bron filter, its implementation principle is. False positive refers to.
The difference between 9.memcache and Redis
10.zookeeper what is the function of the election algorithm?
11.map/reduce process, how to use map/reduce to realize joint statistics of two data sources

X. Design Patterns and reconstruction

1. You can give examples of several common design patterns  
2. What principles do you follow when designing a factory package?  
3. Can you list an open source project/library that uses the Visitor/decorator mode?  
4. What are the most common design patterns you use when coding? In what scenario.  
5. How to implement a single case.  
6. Proxy mode (dynamic proxy)  
7. Singleton mode (lazy mode, Bad Han mode, how concurrent initialization is resolved, volatile and lock use)  
8. JDK source code inside what makes you impressive design patterns use, for example.  

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.