首頁 > Java > java教程 > 主體

java面試知識點

angryTom
發布: 2019-08-10 17:47:02
轉載
2738 人瀏覽過

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 個位元組)

java面試知識點




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 時,抽象類別的方法預設存取權變成default

  2)關於介面

   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:

java面試知識點

Recommended tutorial: Java Basic Introduction Video

Original address: https://blog.csdn.net/qq_33945246/article/details/90040041

以上是java面試知識點的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:csdn.net
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
作者最新文章
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!