### OCA考試大綱
#### Java Basics 基礎
- Define the scope of variables 定義變量的作用范圍
- Define the structure of a Java class 定義一個 Java 類的結構
- Create executable Java applications with a main method; run a Java program from the command line; produce console output 創建包含一個 main 方法的可執行 Java 應用程序;從命令行運行一個 Java 程序;產生控制臺輸出
- Import other Java packages to make them accessible in your code 導入其他 Java 包使其可在你的代碼中使用
- Compare and contrast the features and components of Java such as: platform independence, object orientation, encapsulation, etc. 比較和對比 Java 的特性和組件,例如:平臺獨立性,面向對象,封裝等
#### Using Operators and Decision Constructs 使用操作符和條件判斷結構
- Use Java operators; use parentheses to override operator precedence 使用操作符;使用括號覆蓋操作符優先級
- Test equality between Strings and other objects using `==` and `equals ()` 使用 `==` 和 `equals()` 檢查字符串和其他對象之間的相等性
- Create if and if/else and ternary constructs 創建 if 和 if/else 已經三元(條件)結構
- Use a switch statement 使用 switch 語句
#### Using Loop Constructs 使用循環結構
- Create and use `while` loops 創建并使用 while 循環
- Create and use `for` loops including the enhanced for loop 創建并使用 for 循環,包括增強版 for 循環
- Create and use do/while loops 創建并使用do/while 循環
- Compare loop constructs 比較循環結構
- Use `break` and `continue` 使用 break 和 continue
#### Working with Inheritance 使用繼承
- Describe inheritance and its benefits 描述繼承及其好處
- Develop code that makes use of polymorphism; develop code that overrides methods; differentiate between the type of a reference and the type of an object 開發應用到了多態的代碼;開發重寫方法的代碼;區分引用的類型和對象的類型
- Determine when casting is necessary 確定何時類型轉換時必要的
- Use `super` and `this` to access objects and constructors 使用 super 和 this 訪問對象和構造方法
- Use abstract classes and interfaces 使用抽象類和接口
#### Working with Selected classes from the Java API 使用從 Java API 中選擇的類
- Manipulate data using the `StringBuilder` class and its methods 使用 StringBuilder 類及其方法去操作數據
- Create and manipulate Strings 創建并操作字符串
- Create and manipulate calendar data using classes from `java.time.LocalDateTime`, `java.time.LocalDate`, `java.time.LocalTime`,`java.time.format.DateTimeFormatter`, `java.time.Period` 創建并操縱日歷數據,使用這些類:`java.time.LocalDateTime`, `java.time.LocalDate`, `java.time.LocalTime`,`java.time.format.DateTimeFormatter`, `java.time.Period`
- Declare and use an `ArrayList` of a given type 聲明并使用某個類型的 `ArrayList`
- Write a simple Lambda expression that consumes a Lambda Predicate expression 編寫一個簡單的 Lambda 表達式,要求一個 Lambda Predicate 表達式
#### Working With Java Data Types 使用 Java 數據類型
- Declare and initialize variables (including casting of primitive data types) 聲明并初始化變量(包括原始數據類型的轉換)
- Differentiate between object reference variables and primitive variables 區分對象引用變量和原始變量
- Know how to read or write to object fields 知道如何讀或寫對象字段
- Explain an Object's Lifecycle (creation, "dereference by reassignment" and garbage collection) 解釋一個對象的生命周期(創建,“重新賦值解引用” 和垃圾回收)
- Develop code that uses wrapper classes such as `Boolean`, `Double`, and `Integer` 開發使用封裝類的代碼,例如 Boolean, Double 和 Integer
#### Creating and Using Arrays 創建并使用數組
- Declare, instantiate, initialize and use a one-dimensional array 聲明,實例化,初始化以及使用一維數組
- Declare, instantiate, initialize and use multi-dimensional arrays 聲明,實例化,初始化以及使用多維數組
#### Working with Methods and Encapsulation 使用方法和封裝
- Create methods with arguments and return values; including overloaded methods 創建帶參數和返回值的方法
- Apply the `static` keyword to methods and fields 在方法和字段應用 static 關鍵字
- Create and overload constructors; differentiate between default and user defined constructors 創建并重載構造方法;區分默認和用戶定義構造方法
- Apply access modifiers 應用訪問修飾符
- Apply encapsulation principles to a class 對類應用封裝原則
- Determine the effect upon object references and primitive values when they are passed into methods that change the values 確定對象引用和原始變量傳遞到會改變值的方法時的效果 (考察引用傳遞還是值傳遞)
#### Handling Exceptions 處理異常
- Differentiate among checked exceptions, unchecked exceptions, and Errors 區分檢查異常,非檢查異常以及錯誤
- Create a try-catch block and determine how exceptions alter normal program flow 創建一個 try-catch 語句塊并確定異常時如何改變正常的程序控制流的
- Describe the advantages of Exception handling 描述異常處理的優點
- Create and invoke a method that throws an exception 創建并調用一個會拋出異常的方法
- Recognize common exception classes (such as `NullPointerException`, `ArithmeticException`, `ArrayIndexOutOfBoundsException`, `ClassCastException`) 識別常見的異常類(例如 空指針異常,算術異常,數組越界異常,類型轉換異常)
#### Assume the following: 默認以下情況:
- **Missing package and import statements:** If sample code do not include package or import statements, and the question does not explicitly refer to these missing statements, then assume that all sample code is in the same package, or import statements exist to support them.
**缺失的包和導入語句:**如果示例代碼沒有包含包或導入語句,并且問題沒有明示這些缺失的語句,那么認為所有的示例代碼是在同一個包,或者存在導入它們的導入語句。
- No file or directory path names for classes:
類沒有文件名或者目錄路徑名:
If a question does not state the file names or directory locations of classes, then assume one of the following, whichever will enable the code to compile and run:
如果問題沒有提及到類的文件名或者目錄位置,那么假設以下幾點,能讓代碼編譯并運行即可:
- All classes are in one file 所有類是在同一個文件
- Each class is contained in a separate file, and all files are in one directory
每個類分別存在與不同的文件,并且所有文件都在同一個目錄
- **Unintended line breaks:** Sample code might have unintended line breaks. If you see a line of code that looks like it has wrapped, and this creates a situation where the wrapping is significant (for example, a quoted String literal has wrapped), assume that the wrapping is an extension of the same line, and the line does not contain a hard carriage return that would cause a compilation failure.
**意外的換行:**示例代碼可能由非預期的換行。如果你看到一行代碼看起來軟換行了,并且它造成了一個情形,換行的影響是重要的(例如,一個雙引號括起來的字符串常量換行了),假設那個換行是同一行的延申,且該行不包含導致編譯失敗的硬回車換行。
- **Code fragments:** A code fragment is a small section of source code that is presented without its context. Assume that all necessary supporting code exists and that the supporting environment fully supports the correct compilation and execution of the code shown and its omitted environment.
**代碼片段:**一個代碼片段是不帶有上下文出現的一小節代碼片段。假設所有必要的支持代碼存在并且支持的環境能保證呈現的代碼片段及其省略的部分能夠正確執行。
- **Descriptive comments:** Take descriptive comments, such as "setter and getters go here," at face value. Assume that correct code exists, compiles, and runs successfully to create the described effect.
**描述性注釋:**將描述性注釋,例如“setter 和 getters 在這里” 按字面意思理解。假設正確的代碼存在,編譯、運行成功產生所描述的效果。
- 0.考試大綱解讀
- 1.內容簡介與環境搭建
- 1.1內容簡介
- 1.2.在Windows安裝JDK8
- 2.Java基礎
- 2.1.Java類結構
- 2.2.main方法
- 2.3.注釋
- 2.4.package與import
- 2.5.命名沖突與代碼格式
- 2.6.靜態導入
- 2.7.理解原始數據類型
- 2.8.整數型原始類型
- 2.9.小數型原始類型
- 2.10.原始char與boolean
- 2.11.聲明和初始化變量
- 2.12.理解原始類型變量的默認初始化
- 2.13.變量作用范圍
- 2.14.類里面元素的順序
- 2.15.理解null
- 2.16.原始類型的包裝類
- 2.17.Java的好處
- 2.18.考試題目舉例
- 3.操作符
- 3.1.理解操作符
- 3.2.算術操作符
- 3.3.數值類型提升以及類型轉換
- 3.4.一元操作符第一部分
- 3.5.一元操作符第二部分
- 3.6.賦值運算符
- 3.7.復合賦值運算符
- 3.8.關系操作符
- 3.9.關系操作符
- 3.10.相等操作符
- 3.11.理解 == 與 equals()方法
- 3.12.字符算術運算
- 3.13.考試題目舉例
- 4.基本程序控制流
- 4.1.if else語句
- 4.2.三元操作符
- 4.3.switch語句
- 4.4.while循環
- 4.5.do-while循環
- 4.6.for循環
- 4.7.考試題目舉例
- 5.理解字符串類型
- 5.1.創建字符串以及字符串連接
- 5.2.理解不可變性
- 5.3.字符串常量池和字符串相等
- 5.4.String類的方法第一部分
- 5.5.String類的方法第二部分
- 5.6.方法串聯
- 5.7.使用StringBuilder類
- 5.8.StringBuilder類的方法
- 5.9.理解相等性
- 5.10.考試題目舉例
- 6.數組
- 6.1.理解數組
- 6.2.使用數組
- 6.3.數組常見的問題
- 6.4.For-each循環
- 6.5.break語句和標簽
- 6.6.continue語句
- 6.7.數據排序
- 6.8.搜索數組
- 6.9.可變數量參數
- 6.10多維數組
- 6.11嵌套循環
- 6.12考試題目舉例
- 7.ArrayList
- 7.1.理解ArrayList
- 7.2.ArrayList的方法第一部分
- 7.3.ArrayList的方法第二部分
- 7.4.在ArrayList使用包裝類
- 7.5.ArrayList與數組之間的轉換
- 7.6.ArrayList元素排序
- 7.7.搜索ArrayList
- 7.8.遍歷List第一部分
- 7.9.遍歷List第二部分
- 7.10.考試題目舉例
- 8.方法
- 8.1.設計一個方法
- 8.2.方法的返回類型
- 8.3.方法的參數列表
- 8.4.帶有數量可變參數的方法
- 8.5.訪問修飾符
- 8.6.靜態方法和字段
- 8.7.使用靜態方法和字段第一部分
- 8.8.使用靜態方法和字段第二部分
- 8.9.final方法
- 8.10.靜態初始化
- 8.11.在方法之間傳輸數據
- 8.12.方法的返回數據
- 8.13.重載方法
- 8.14.考試題目舉例
- 9.類設計
- 9.1.類的構造函數
- 9.2.默認構造函數
- 9.3.構造方法重載
- 9.4.this 與 this()的區別
- 9.5.初始化的順序
- 9.6.數據封裝
- 9.7.不可變類
- 9.8.類與繼承第一部分
- 9.9.類與繼承第二部分
- 9.10方法重寫
- 9.11.super 與 super()的區別
- 9.12.重載與重寫的區別
- 9.13.抽象類
- 9.14.抽象方法
- 9.15.創建接口
- 9.16.實現接口
- 9.17.接口的默認方法
- 9.18.接口的靜態方法
- 9.19.抽象類與接口的區別
- 9.20.多態
- 9.21.虛方法
- 9.22.參數多態
- 9.23.考試題目舉例
- 10.Java 8的日期和時間API
- 10.1.創建日期與時間
- 10.2.使用日期與時間
- 10.3.Periods
- 10.4.格式化日期和時間
- 10.5.解釋日期和時間
- 10.6.考試題目舉例
- 11.異常處理
- 11.1.理解異常處理
- 11.2.Checked 與 Unchecked 異常的區別
- 11.3.處理異常
- 11.4.使用finally語句塊
- 11.5.捕獲不同的異常
- 11.6.return 和 finally塊
- 11.7.拋出異常的方法
- 11.8.考試題目舉例
- 12.簡單的Lambda表達式
- 12.1.理解Lambda
- 12.2.使用Lambda
- 12.3.Predicates
- 12.4.考試問題舉例
- 13.福利
- 13.1.Anki記憶卡片