java面試知識點
1、Java文件經過JVM編譯成字節碼文件,即.class文件,將字節碼文件在不同的作業系統中運行時,作業系統再將字節碼檔編譯成機器碼檔。這就是Java跨平台
2、首先明確一點,java 的GC 回收是完全自動的,沒有提供相關api 手動回收,所有的記憶體分配和回收權限都在jvm,在開發人員手上沒有絕對的強制垃圾回收的方法,不過可以這樣去做:
1)對於不再引用的對象,及時把它的引用賦為null。 obj = null;
2)如果記憶體確實很緊張,呼叫 System.gc () 方法來建議垃圾回收器開始回收垃圾,通知 GC 運行,但是 Java 語言規格不保證 GC 一定會執行。
3、java 基本類型的預設值和取值範圍
整數類型byte(1 個位元組)short(2 個位元組)int(4 個位元組)長(8 個位元組)
字元類型char(2 個位元組)
浮點數類型float(4 個位元組)double(8 個位元組)
4、常見字元的ASCII碼值如下:空格的ASCII碼值為32;數字0到9的ASCII碼值分別為48到57;大寫字母“A”到「Z」的ASCII碼值分別為65到90;小寫字母「a」到「z」的ASCII碼值分別為97到到122。
5、Java 識別碼有以下命名規則: 1)由26 個英文字母大小寫,數字:0-9 符號:_ $ ¥ 組成# 2)標識符應以字母、_ 、$ 開頭。3)標識符不能是關鍵字。
6、抽象類別與介面 1)關於抽象類別 JDK 1.8 先前,抽象類別的方法預設存取權限為protected # JDK 1.8 時,抽象類別的方法預設存取權變成default2)關於介面
JDK 1.8 以前,在介面中的方法必須是public 的「 」 JDK JK 1.8 時,介面中的方法可以是public 的,也可以是default 的
JDK 1.9 時,介面中的方法可以是private 的
7、裝箱和拆解箱 基本資料型別轉換成包裝類別是裝箱(如: int --> Integer)。 包裝類別轉換成基本資料型別就是拆箱 (如:Integer --> int)。 包裝類別就是參考類型,基本資料型別就是值型別。 透過 裝箱 和 拆箱 操作,能夠在值型別和參考型別中架起一做橋樑。換言之,可以輕鬆的實現值類型與引用類型的互相轉換,裝箱和拆箱能夠統一考察系統,任何類型的值最終都可以按照對象進行處理。
8、序列化與反序列化Java 在序列化時不會實例化static 變數和transient 修飾的變數,因為static 代表類別的成員,transient 代表對象的臨時數據,被宣告這兩種類型的資料成員不能被序列化
9、Java有兩種傳遞方式,值傳遞和引用傳遞。基本型別和以string str = “aaa”;這種方式創建的都是值傳遞,物件建立和陣列都是引用傳遞,所以在函數的判斷形參需要特別注意。
10、Java垃圾回收機制
### 垃圾回收主要針對的是堆區的回收,因為堆疊區的記憶體是隨著執行緒而釋放的。堆區分為三個區:年輕代(Young Generation)、年老代(Old Generation)、永久代(Permanent Generation,也就是方法區)。 ###### 1)年輕代:物件被創建時(new)的物件通常被放在Young(除了一些佔據記憶體比較大的物件), 經過一定的Minor GC(針對年輕代的記憶體回收)還活著的對象會被移動到年老代(一些具體的移動細節省略)。 ###### 2)年老代:就是上述年輕代移動過來的和一些比較大的對象。 Major GC (FullGC) 是針對年長世代的回收。 ###### 3)永久代:儲存的是 final 常數,static 變量,常數池。 #########11、套件引用###### import java.util.* ;###### 能存取java/util目錄下的所有類,不能存取java/util子目錄下的所有類別#########12、建構子不能被繼承,建構方法只能被明確或隱式的呼叫。 (有參和無參都這樣)###13. Files are divided into text files and binary files. Computers only understand binary, so they are actually different ways of interpreting binary. Text files are characters displayed in different encoding formats, such as Ascii, Unicode, etc. The suffix names of text files in window include ".txt", ".log", source code files of various programming languages, etc. Binary files are text documents. You can't read garbled characters when you open them. As long as the file can be opened with text, it can be regarded as a text file, but the displayed result is not what you want. Binary files can only be read with special applications, such as ".png"," .bmp", etc., most of the files in the computer are still binary files
14. try is only suitable for handling runtime exceptions, while try catch is suitable for handling ordinary runtime exceptions. In other words, if you only use try to handle ordinary exceptions without using catch, the compilation will not pass, because the compiler rigidly stipulates that if ordinary exceptions are caught, they must be explicitly declared with catch for further processing. There is no such provision for runtime exceptions at compile time, so catch can be omitted. It is understandable for the compiler to add catch.
15. Pipeline
For pipelines, there are the following types:
① Ordinary pipeline (PIPE): There are usually two restrictions, one is single Work, that is, it can only be transmitted in one direction; second, blood, which is often used between father and son processes (or between processes with blood relationships).
②Stream pipe (s_pipe): The first restriction mentioned above is removed and bidirectional transmission is realized.
③Named pipe (name_pipe): Removes the second restriction mentioned above and realizes communication between different processes that are not related by blood.
The requirement is that the communication between different servers must be in full-duplex form, while the pipeline can only be half-duplex. Although it can be bidirectional, there can only be transmission in one direction at the same time. The difference between duplex and half-duplex can be understood as follows:
Recommended tutorial: Java Basic Introduction Video
Original address: https://blog.csdn.net/qq_33945246/article/details/90040041
以上是java面試知識點的詳細內容。更多資訊請關注PHP中文網其他相關文章!

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

Java 8引入了Stream API,提供了一種強大且表達力豐富的處理數據集合的方式。然而,使用Stream時,一個常見問題是:如何從forEach操作中中斷或返回? 傳統循環允許提前中斷或返回,但Stream的forEach方法並不直接支持這種方式。本文將解釋原因,並探討在Stream處理系統中實現提前終止的替代方法。 延伸閱讀: Java Stream API改進 理解Stream forEach forEach方法是一個終端操作,它對Stream中的每個元素執行一個操作。它的設計意圖是處

PHP是一種廣泛應用於服務器端的腳本語言,特別適合web開發。 1.PHP可以嵌入HTML,處理HTTP請求和響應,支持多種數據庫。 2.PHP用於生成動態網頁內容,處理表單數據,訪問數據庫等,具有強大的社區支持和開源資源。 3.PHP是解釋型語言,執行過程包括詞法分析、語法分析、編譯和執行。 4.PHP可以與MySQL結合用於用戶註冊系統等高級應用。 5.調試PHP時,可使用error_reporting()和var_dump()等函數。 6.優化PHP代碼可通過緩存機制、優化數據庫查詢和使用內置函數。 7

PHP和Python各有優勢,選擇應基於項目需求。 1.PHP適合web開發,語法簡單,執行效率高。 2.Python適用於數據科學和機器學習,語法簡潔,庫豐富。

PHP適合web開發,特別是在快速開發和處理動態內容方面表現出色,但不擅長數據科學和企業級應用。與Python相比,PHP在web開發中更具優勢,但在數據科學領域不如Python;與Java相比,PHP在企業級應用中表現較差,但在web開發中更靈活;與JavaScript相比,PHP在後端開發中更簡潔,但在前端開發中不如JavaScript。

PHP和Python各有優勢,適合不同場景。 1.PHP適用於web開發,提供內置web服務器和豐富函數庫。 2.Python適合數據科學和機器學習,語法簡潔且有強大標準庫。選擇時應根據項目需求決定。

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP成為許多網站首選技術棧的原因包括其易用性、強大社區支持和廣泛應用。 1)易於學習和使用,適合初學者。 2)擁有龐大的開發者社區,資源豐富。 3)廣泛應用於WordPress、Drupal等平台。 4)與Web服務器緊密集成,簡化開發部署。

PHP適用於Web開發和內容管理系統,Python適合數據科學、機器學習和自動化腳本。 1.PHP在構建快速、可擴展的網站和應用程序方面表現出色,常用於WordPress等CMS。 2.Python在數據科學和機器學習領域表現卓越,擁有豐富的庫如NumPy和TensorFlow。
