2018 java interview summary (fine)

1. Basic grammar

This includes the role of static, final, transient and other keywords, the principle of foreach loop, and so on. In today's interview, I asked you what the static keyword does. If you answer static modified variables and modified methods, I will think you are qualified. If you answer static blocks, I will think you are good. If you answer static inner classes, I will think you are very good. , I will be very satisfied with the static guide package , because I can see that you are very keen on researching technology.

An interview experience that impressed me a lot, the interviewer directly asked me the underlying implementation principle of the volatile keyword (by the way, the interview and being interviewed are themselves relative, the interviewer asking this question also makes the interviewer feel the interviewer He is also a person who likes to study technology, which increases the good impression of the interviewer on the company. I finally chose the company that asked this question), don't think this is too nitpicky - the simpler the question, the better you can tell a person The level of your technology, most of others' consideration of your technology is based on depth first and breadth second, remember. Don't answer too shallowly, so most of the interviews will not be successful, because on the one hand the interviewer thinks that you are not skilled, you can't study things, and there is no need for training; on the other hand, the interviewer thinks that you don't understand this knowledge, but you can use it!

2. Collection

Very important and a must ask.

Basically it is List, Map, Set. It asks about the underlying implementation principles of various implementation classes, and the advantages and disadvantages of implementation classes.

The collection needs to master the implementation principles of ArrayList, LinkedList, Hashtable, HashMap, ConcurrentHashMap, and HashSet. It is good to be able to answer fluently, of course, to master the CopyOnWrite container and Queue.

Note: In addition , the question of ConcurrentHashMap is asked a lot in the interview, probably because this class can derive a lot of questions. Regarding ConcurrentHashMap, I provide three answers or research directions:

  Lock Segmentation Technology of ConcurrentHashMap

  Does the reading of ConcurrentHashMap need to be locked and why?

  Is the iterator of ConcurrentHashMap a strongly consistent iterator or a weakly consistent iterator

3. Design Patterns

I thought it was an important piece of content, but it turned out to be only asked once during the interview of Alibaba B2B business department. At that time, it was the decorator mode .

Of course, we can’t be so utilitarian. We learn for interviews. Design patterns are still very important and useful in our work. Among the 23 design patterns, we can focus on a dozen commonly used ones . In basic interviews, many companies will let you write a Design pattern code;

The questions and answers about design patterns in the interview are mainly:

  •   What design patterns are used in your project and how to use them
  •   Know the pros and cons of common design patterns
  •   Can draw UML diagrams of common design patterns
  •      handwritten code

4. Multithreading

This is also a must ask. Because of three years of work experience, I will basically not ask you how to implement multi-threading, but will ask more deeply;

For example , the difference and connection between Thread and Runnable, what happens when a thread is started multiple times, and what status does the thread have . Of course this is just the basics; go a little deeper:

  • The thread pool is also a frequently asked question. How many types of thread pools are commonly used? What are the differences and connections between these types of thread pools? What is the implementation principle of the thread pool? In practice, it will give you some specific scenarios and let you answer what kind of thread pool is appropriate for this scenario.
  • Multi-threaded synchronization and locks are also key points. The difference between synchronized and ReentrantLock, synchronized lock common method and lock static method, deadlock principle and troubleshooting method, etc...

Unexpectedly, several interviews were almost all asked a question at the same time, and the way of asking is different. It is summed up as follows:

If there are four threads Thread1, Thread2, Thread3, and Thread4 to count the sizes of the four disks C, D, E, and F respectively, and all the threads are counted and handed over to the Thread5 thread for summarization, how should it be implemented?

Do you have an answer to this question? Not difficult, there are ready-made classes available under java.util.concurrent.

5、 IO

IO分为File IO和Socket IO,File IO基本上是不会问的,问也问不出什么来,平时会用就好了,另外记得File IO都是阻塞IO。

Socket IO是比较重要的一块,要搞懂的是阻塞/非阻塞的区别、同步/异步的区别,借此理解阻塞IO、非阻塞IO、多路复用IO、异步IO这四种IO模型,Socket IO如何和这四种模型相关联。这是基本一些的,深入一些的话,就会问NIO的原理、NIO属于哪种IO模型、NIO的三大组成等等,这有些难,当时我也是研究了很久才搞懂NIO。

吐舌头提一句,NIO并不是严格意义上的非阻塞IO而应该属于多路复用IO,面试回答的时候要注意这个细节,讲到NIO会阻塞在Selector的select方法上会增加面试官对你的好感。

6、JDK源码

生气要想拿高工资,JDK源码不可不读。

上面的内容可能还和具体场景联系起来,JDK源码就是实打实地看你平时是不是爱钻研了。我面试过程中被问了不少JDK源码的问题,其中最刁钻的一个问题——String的hashCode()方法是怎么实现的,幸好我平时String源代码看得多,答了个大概。JDK源码其实没什么好总结的,纯粹看个人,总结一下比较重要的源码:

  •   List、Map、Set实现类的源代码
  •   ReentrantLock、AQS的源代码
  •   AtomicInteger的实现原理,主要能说清楚CAS机制并且AtomicInteger是如何利用CAS机制实现的
  •   线程池的实现原理
  •   Object类中的方法以及每个方法的作用

这些其实要求蛮高的,我去年一整年基本把JDK中重要类的源代码研究了个遍,真的花费时间、花费精力,当然回头看,是值得的----不仅仅是为了应付面试。

7、 框架

老生常谈,面试必问的东西。ssh/ssm/ssi   前端也会问

一般来说会问你一下你们项目中使用的框架,然后给你一些场景问你用框架怎么做;

比如我想要在spring初始化bean的时候做一些事情该怎么做、想要在bean销毁的时候做一些事情该怎么做、MyBatis中$和#的区别等等,这些都比较实际了,平时积累得好、有多学习框架的使用细节自然都不成问题。

如果上面你的问题答得好,面试官往往会深入地问一些框架的实现原理。问得最多的就是Spring AOP的实现原理,当然这个很简单啦,两句话就搞定的的事儿,即使你不会准备一下就好了。

8、数据库

数据库十有八九也都会问到。

一些基本的像union和union all的区别、left join、几种索引及其区别就不谈了;

比较重要的就是数据库性能的优化,花一两天专门把SQL基础和SQL优化的内容准备一下。

9、数据结构和算法

每次都会问,而且基本开场让写代码:偷笑

数组、链表是基础,栈和队列深入一些但也不难,树挺重要的,比较重要的树AVL树、红黑树,了解它们的具体实现(写代码。因为遇到很多上来就说写手写代码吧),要知道什么是二叉查找树、什么是平衡树,AVL树和红黑树的区别。记得某次面试,某个面试官和我聊到了数据库的索引,他问我:

你知道索引使用的是哪种数据结构实现吗?

索引为什么要使用树来实现呢?

至于算法,

红黑树、排序算法、冒泡排序、二分查找手写代码

10、 Java虚拟机

Java虚拟机应该是很重要的一块内容;

谈谈Java虚拟机中比较重要的内容:

  •   Java虚拟机的内存布局
  •   GC算法及几种垃圾收集器
  •   类加载机制,也就是双亲委派模型
  •   Java内存模型
  •   happens-before规则
  •   volatile关键字使用规则

11、Web方面的一些问题

基本注重技术的公司会在web方面少问,因为问这个考察东西有限,基本面试者在面试前两天看一下相关内容就可以了;但是要深入理解,还是要看平常;

Java主要面向Web端,因此Web的一些问题也是必问的。我碰到过问得最多的两个问题是:

  1.谈谈分布式Session的几种实现方式

常用的四种能答出来自然是让面试官非常满意的,另外一个常问的问题是:

  2.讲一下Session和Cookie的区别和联系以及Session的实现原理

这两个问题之外,web.xml里面的内容是重点,Filter、Servlet、Listener,不说对它们的实现原理一清二楚吧,至少能对它们的使用知根知底。另外,一些细节的方面比如get/post的区别、forward/重定向的区别、HTTPS的实现原理。

12、缓存、消息队列


 
 
redis为什么可以做缓存?项目中使用redis的目的是什么?redis什么时候使用?
1)Redis是key-value形式的nosql数据库。可以快速的定位到所查找的key,并把其中的value取出来。并且redis的所有的数据都是放到内存中,存取的速度非常快,一般都是用来做缓存使用。
2)项目中使用redis一般都是作为缓存来使用的,缓存的目的就是为了减轻数据库的压力提高存取的效率。
3)在互联网项目中只要是涉及高并发或者是存在大量读数据的情况下都可以使用redis作为缓存。当然redis提供丰富的数据类型,除了缓存还可以根据实际的业务场景来决定redis的作用。例如使用redis保存用户的购物车信息、生成订单号、访问量计数器、任务队列、排行榜等。
redis支持五种数据类型存储:1.字符串2.散列3.列表4.集合5.有序集合
redis集群中,某个节点宕机怎么办?你遇见过吗?你的解决思路是什么?
redis集群:一般的是至少是2台服务器,主从服务器!如果redis集群的主服务器挂了,没有关系还有备服务器
AcitveMQ的作用、原理、特点?(生产者。消费者。 p2p、订阅实现流程)
Activemq的作用就是系统之间进行通信。当然可以使用其他方式进行系统间通信,如果使用Activemq的话可以对系统之间的调用进行解耦,实现系统间的异步通信。原理就是生产者生产消息,把消息发送给activemq。Activemq接收到消息,然后查看有多少个消费者,然后把消息转发给消费者,此过程中生产者无需参与。消费者接收到消息后做相应的处理和生产者没有任何关系。
当技术面试官问到你某个技术点更深层次研究时,自己没有深入了解怎么回答?

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324791849&siteId=291194637