面试日记——阿里巴巴JAVA面试

系统管理员 2022-05-29 04:46 372阅读 0赞

面试日记——阿里巴巴JAVA面试

阿里的面试是最紧张的一场,也是最考验技术的一场。
没想到阿里的面试通知现在才收到,可以说是迟来的爱吧。
面试的远程的面试,需要共享桌面,在线编程。
到官网上排队,排了1个多小时,总算排到了。
面试我的是一个很年轻的阿里小哥,是架构事业部的。

他主要问我以下几个问题(为了共同的进步,我把答案也写在问题下面,仅供参考)

1. jvm模型

http://www.cnblogs.com/AloneSword/p/4262255.html

2. 类加载器

http://blog.csdn.net/gjanyanlig/article/details/6818655/

3. 垃圾回收分类

http://www.cnblogs.com/davenkin/p/java-garbage-collection.html

4. 查看垃圾回收的命令

http://www.cnblogs.com/wozixiaoyao/p/5658952.html

5. 线程同步的多种方式

http://blog.csdn.net/cengjingyige/article/details/52382300

6. Lucene的底层实现

http://blog.csdn.net/njpjsoftdev/article/details/54015485

7. 数据库MyISAM和InnoDB索引的储存方式

http://www.cnblogs.com/renzherushe/p/4780226.html

8. redis的使用场景

http://blog.jobbole.com/88383/

9. redis如何清除过期数据

http://www.cnblogs.com/zhangchao-letv/articles/6119313.html

10. redis的主机选举机制

http://www.tuicool.com/articles/yiEnUj

11. Treepmap和HsahMap的区别,底层实现

http://www.chinaitlab.com/Java/base/962510.html

12. JavaWeb中Filter使用的是哪种设计模式

过滤器模式
http://www.runoob.com/design-pattern/filter-pattern.html

13. IO包的输入输出流使用哪种设计模式

http://www.cnblogs.com/wxgblogs/p/5649933.html

14. 内部类用哪种方式可以获取

http://blog.csdn.net/qq_32198277/article/details/72593825

15. 编程实现装饰器模式

http://www.runoob.com/design-pattern/decorator-pattern.html

16. 编程实现菜单层级(最多三层)

当时没做出来,现在用最简单的方式来实现
思路是用map来记录选过的,用两个list来记录上次选剩下的和没有选的(其实可以用一个List加迭代器就行)
因为最多三层,所以最多用3个for循环就好

  1. import java.util.*;
  2. public class Main {
  3. class Menu{
  4. private int id;
  5. private String name;
  6. private int pId;
  7. public Menu(int id, String name, int pId) {
  8. this.id = id;
  9. this.name = name;
  10. this.pId = pId;
  11. }
  12. public int getId() {
  13. return id;
  14. }
  15. public void setId(int id) {
  16. this.id = id;
  17. }
  18. public String getName() {
  19. return name;
  20. }
  21. public void setName(String name) {
  22. this.name = name;
  23. }
  24. public int getpId() {
  25. return pId;
  26. }
  27. public void setpId(int pId) {
  28. this.pId = pId;
  29. }
  30. }
  31. class Result{
  32. private Menu menu;
  33. private List<Result>menus=new ArrayList<>();
  34. public Menu getMenu() {
  35. return menu;
  36. }
  37. public void setMenu(Menu menu) {
  38. this.menu = menu;
  39. }
  40. public List<Result> getMenus() {
  41. return menus;
  42. }
  43. public void setMenus(List<Result> menus) {
  44. this.menus = menus;
  45. }
  46. }
  47. public void test(){
  48. List<Menu> menuList=new ArrayList<>();
  49. Menu menu1=new Menu(1,"1",0);
  50. Menu menu2=new Menu(2,"2",1);
  51. Menu menu3=new Menu(4,"4",1);
  52. Menu menu4=new Menu(3,"3",2);
  53. Menu menu5=new Menu(5,"5",2);
  54. Menu menu6=new Menu(6,"6",2);
  55. menuList.add(menu4);
  56. menuList.add(menu1);
  57. menuList.add(menu2);
  58. menuList.add(menu3);
  59. menuList.add(menu5);
  60. menuList.add(menu6);
  61. List<Menu> menuList2=new ArrayList<>(menuList);
  62. Map<Integer,Result> resultMap=new HashMap<Integer,Result>();
  63. List<Result>results=new ArrayList<Result>();
  64. //先找第一层的
  65. for (Menu menu:menuList){
  66. if (menu.getpId()==0){
  67. Result result=new Result();
  68. result.setMenu(menu);
  69. //放进map,表示已经被选过
  70. resultMap.put(menu.getId(),result);
  71. results.add(result);
  72. //移除选过的
  73. menuList2.remove(menu);
  74. }
  75. }
  76. //menuList和menuList2身份互换
  77. menuList.clear();
  78. menuList.addAll(menuList2);
  79. //扫描找到第二层或第三层的
  80. for (Menu menu:menuList2){
  81. Result result=resultMap.get(menu.getpId());
  82. if (result!=null){
  83. Result result1=new Result();
  84. result1.setMenu(menu);
  85. resultMap.put(menu.getId(),result1);
  86. result.getMenus().add(result1);
  87. menuList.remove(menu);
  88. }
  89. }
  90. //menuList和menuList2身份互换
  91. //扫描找到第三层剩下的
  92. for (Menu menu:menuList){
  93. Result result=resultMap.get(menu.getpId());
  94. if (result!=null){
  95. Result result1=new Result();
  96. result1.setMenu(menu);
  97. result.getMenus().add(result1);
  98. resultMap.put(menu.getId(),result1);
  99. }
  100. }
  101. }
  102. public static void main(String[] args) {
  103. Main main=new Main();
  104. main.test();
  105. }
  106. }
  107. 1
  108. 2
  109. 3
  110. 4
  111. 5
  112. 6
  113. 7
  114. 8
  115. 9
  116. 10
  117. 11
  118. 12
  119. 13
  120. 14
  121. 15
  122. 16
  123. 17
  124. 18
  125. 19
  126. 20
  127. 21
  128. 22
  129. 23
  130. 24
  131. 25
  132. 26
  133. 27
  134. 28
  135. 29
  136. 30
  137. 31
  138. 32
  139. 33
  140. 34
  141. 35
  142. 36
  143. 37
  144. 38
  145. 39
  146. 40
  147. 41
  148. 42
  149. 43
  150. 44
  151. 45
  152. 46
  153. 47
  154. 48
  155. 49
  156. 50
  157. 51
  158. 52
  159. 53
  160. 54
  161. 55
  162. 56
  163. 57
  164. 58
  165. 59
  166. 60
  167. 61
  168. 62
  169. 63
  170. 64
  171. 65
  172. 66
  173. 67
  174. 68
  175. 69
  176. 70
  177. 71
  178. 72
  179. 73
  180. 74
  181. 75
  182. 76
  183. 77
  184. 78
  185. 79
  186. 80
  187. 81
  188. 82
  189. 83
  190. 84
  191. 85
  192. 86
  193. 87
  194. 88
  195. 89
  196. 90
  197. 91
  198. 92
  199. 93
  200. 94
  201. 95
  202. 96
  203. 97
  204. 98
  205. 99
  206. 100
  207. 101
  208. 102
  209. 103
  210. 104
  211. 105
  212. 106
  213. 107
  214. 108
  215. 109
  216. 110
  217. 111
  218. 112
  219. 113
  220. 114
  221. 115
  222. 116
  223. 117
  224. 118
  225. 119
  226. 120
  227. 121

这次面试虽然是视频面试但毕竟是阿里的面试,所以难度还真不小,导致我太紧张,最后一题编程题非常简单也没做出来,如果你们有更好的答案也可以在评论区留言,一起加油。

发表评论

表情:
评论列表 (有 0 条评论,372人围观)

还没有评论,来说两句吧...

相关阅读

    相关 阿里面试题总结

    1. 在JVM中,类从被加载到虚拟机内存中开始,到卸载出内存为止,它的整个生命周期包括哪几个阶段? 答:7个阶段,分别是:加载、验证、准备、解析、初始化、使用和卸载。  

    相关 阿里电话面试总结

    阿里巴巴电话面试总结   1. 谈一谈你对反射机制的理解。 (官方概念)在程序运行状态中,对于任意一个类,都能够知道它的所有属性和方法,对于任意一个对象,都能够调用