日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java高级工程师开放面试题集一

發布時間:2025/4/5 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java高级工程师开放面试题集一 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?

臨近年關,不少人蠢蠢欲動,有童鞋問我java后端面試會面試什么?

作為一個java后端老鳥,跌打滾爬多次被面試和面試別人,總結了一些經驗,希望對大家有所幫助。

特別說明,僅僅針對工作兩年以上的java后端開發。以開放性題目為主。

1.數據結構相關

? 假設1億整數存放在一個txt文件中,如何去重和排序?

? 思路:

? 1.1.面試者要評估一下一億整數的大小。一個int占4個字節,1億呢?

? 1.2.去重的數據結構有哪些?HashSet--->引申到HashMap--->ConcurrentHashMap?

? 1.3 數據量增大到十億百億怎么去重?

  布隆過濾器,優點,缺點

? 1.4.其他方式?

??  數據庫distinct order by,txt怎么導入到數據庫?load

? ? ? ? ?redis去重排序,redis的數據結構-->引申到其他數據結構 String,list,hash,set,sorted set,hyperloglog,geo

? ? ? ? mongo去重排序,

? ? ? ? ....

2. 算法相關,主要考察代碼能力

? ?斐波那契數列(fabnacci)實現,首先介紹一下該算法的思想

  

? ? 2.1 第一級別實現: 兩層遞歸

public static long fibonacci(int n){if(n==0) return 0;else if(n==1) return 1;else return fibonacci(n-1)+fibonacci(n-2);}

問算法復雜度及評估一下性能問題,提示可以優化。

? ? 2.2 第二級別:減少一層遞歸

public static void main(String[] args) {long tmp=0;// TODO Auto-generated method stubint n=10;Long start=System.currentTimeMillis();for(int i=0;i<n;i++){System.out.print(fibonacci(i)+" ");}System.out.println("-------------------------");System.out.println("耗時:"+(System.currentTimeMillis()-start));} public static long fibonacci(int n) {long result = 0;if (n == 0) {result = 0;} else if (n == 1) {result = 1;tmp=result;} else {result = tmp+fibonacci(n - 2);tmp=result;}return result;}

? 問題,算法復雜度,引導有沒有不用遞歸的?

? ? ?2.3 無遞歸

public static long fibonacci(int n){long before=0,behind=0;long result=0;for(int i=0;i<n;i++){if(i==0){result=0;before=0;behind=0;}else if(i==1){result=1;before=0;behind=result;}else{result=before+behind;before=behind;behind=result;}}return result;}

3.并發問題

? ?給出一個普通的spring mvc controller,如下:

@Controller public class WelcomeController {private final Logger logger = LoggerFactory.getLogger(WelcomeController.class);
  @Autowired   private final HelloWorldService helloWorldService;@RequestMapping(value = "/", method = RequestMethod.GET)public String index(Map<String, Object> model) {logger.debug("index() is executed!");model.put("title", helloWorldService.getTitle(""));model.put("msg", helloWorldService.getDesc());return "index";}}

? ?問題:

? ? 3.1.線程模型是什么?單線程

? ? 3. 2.如何提升qps?線程池 executor

? ? 3.3.在線程池下如何控制并發?信號量Semaphore或者計數器CountDownLatch

? ? ? ?引申到:Java中的可重入鎖:synchronized 和 java.util.concurrent.locks.ReentrantLock

? ?

4.數據庫相關

? ? 場景:一張表 test(a,b,c,e,f,g) 100w記錄? 常用查詢條件 ab? abc? abe,如何提升查詢效率?

? ? 4.1.索引,

? ? 4.2.復合索引的規則:最左原則。查詢條件ae走不走索引?

? ? 4.3 1000w,1億,十億以上條記錄查詢是否會有什么不同?

? ? ?4.4 多線程下如何保證數據一致性?樂觀鎖/悲觀鎖,應用場景不同點

?

5.設計模式相關

? ?

public class Test { @Test public void test() throws InterruptedException, ExecutionException { AsyncTaskExecutor executor = new SimpleAsyncTaskExecutor("sys.out"); Future<String> future = executor.submit(new OutThread()); System.out.println(future.get()); System.out.println("Hello, World!"); Thread.sleep(10000 * 1000L); } static class OutThread implements Callable<String> { public void run() { } @Override public String call() throws Exception { String ret = " i test callable"; for (int i = 0; i < 10; i++) { try { Thread.sleep(2 * 1000L); System.out.println("i sleep 1s"); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return ret; } } }

? ? 5.1 看程序說明

? ? 5.2 引申到reactor模型

? ? ? ? ?spring reactor

? ? ? ? ? vert.x

? ? ? ? ? akka

? ? 5.3 servlet 3 響應式編程

太累,先寫到這里吧。

?

轉載于:https://www.cnblogs.com/davidwang456/p/10213337.html

總結

以上是生活随笔為你收集整理的java高级工程师开放面试题集一的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。