教材:耿祥义、张跃平《Java 2 实用教程(第 7 版)》,清华大学出版社,ISBN 978-7-302-69132-7(题库+微课视频版),共 15 章。
结构:基本语法(2~3 章)→ 核心基础(4~7 章)→ 应用基础(8~9 章)→ 专项应用(10~15 章)。
期末通常考到第 8 章 + 第 15 章(集合),第 10/12 章看老师进度。
⚠️ 标注的是必考/必错点。不需要钻算法,能看懂、能写基本语法和栈/队列/排序就够了。
JAVA_HOME、Path).java → javac 编译 → java 运行考点:Java 为什么能跨平台;JDK/JRE/JVM 关系;源文件名与 public 类名必须一致。
Scanner 读基本型(nextInt()、nextDouble()、next()、nextLine())System.out.print/println/printfint[] a;、分配 new int[5]、length 属性(不是方法)、初始化、二维数组ArrayIndexOutOfBoundsException代码题:数组求和/最值/排序;二维数组遍历。
i++/++i、/ 整除、% 负数
// 冒泡
for (int i = 0; i < n - 1; i++)
for (int j = 0; j < n - 1 - i; j++)
if (a[j] > a[j + 1]) { int t = a[j]; a[j] = a[j + 1]; a[j + 1] = t; }
// 选择
for (int i = 0; i < n - 1; i++) {
int k = i;
for (int j = i + 1; j < n; j++) if (a[j] < a[k]) k = j;
int t = a[i]; a[i] = a[k]; a[k] = t;
}
Arrays.sort(a) / Arrays.toString(a)(第 8 章会细讲)newthis 关键字:区分成员/局部、调用本类构造A a1 = new A(); A a2 = a1; 指向同一对象static ⚠️:静态变量/方法/代码块;静态方法不能访问实例成员简答:成员变量与局部变量区别;构造方法特点;this 的作用;static 的特点。
extends、单继承、子类与父类成员访问super:访问父类成员/构造(第一行)final:类(不可继承)、方法(不可重写)、变量(常量)父类 f = new 子类(); 成员方法看实际对象,成员变量看声明类型简答:重写与重载区别;上转型对象的特点;final 的作用。
interface、实现 implements、可多实现abstract 抽象类:不能实例化、可含普通方法;抽象方法try-catch-finally;finally 一定执行(除非 System.exit(0))throw 抛出、throws 声明简答:try-catch-finally 执行顺序;throw 与 throws 区别;自定义异常步骤。
== 比地址、equals 比内容;常量池length/charAt/indexOf/substring/trim/replace/split/toCharArray/toUpperCase/valueOfCalendar.getInstance()、get/set/add、SimpleDateFormat 格式化与解析matches、find、replaceAll)Arrays、Collections 工具类(排序、查找)简答:String 与 StringBuffer 区别;== 与 equals;String 为什么不可变。
File 类:路径、exists/isFile/isDirectory/length/listFileInputStream/FileOutputStream;字符流:FileReader/FileWriterBufferedReader(readLine)、BufferedWriterRandomAccessFile(了解)、对象流(序列化,Serializable)代码题:文件复制、按行读文件、统计字符。
DriverManager.getConnection → Statement/PreparedStatement → 执行 SQL → 关闭ResultSet 遍历;PreparedStatement 防注入 ⚠️Thread 类与 Runnable 接口两种创建方式 ⚠️start/sleep/join/yield/isAlive/setDaemonsynchronized(同步代码块/方法);wait/notify简答:start() 与 run() 区别;为什么需要同步。
Socket / ServerSocket;简单 TCP 通信步骤 ⚠️InetAddress、URL<T> ⚠️:类型安全、避免强转ArrayList(数组,查快)、LinkedList(链表,增删快)HashSet(哈希表,去重)、TreeSet(排序)HashMap、TreeMap;遍历 entrySet() ⚠️
Stack<Integer> st = new Stack<>();
st.push(1); st.peek(); st.pop(); st.isEmpty();
Queue<Integer> q = new LinkedList<>(); // 或 ArrayDeque
q.offer(1); q.peek(); q.poll(); q.isEmpty();
Iterator、增强 forCollections.sort()、Comparator 接口filter/map/collect)简答:ArrayList 与 LinkedList 区别;HashSet 去重原理;List/Set/Map 区别;泛型的作用。
代码题:用集合统计、栈判断括号匹配、队列模拟排队、List 排序(Comparator)。
| 题 | 章 |
|---|---|
| Java 为什么跨平台 | 1 |
| 基本类型与引用类型的区别 | 2 |
i++ 与 ++i、& 与 && | 3 |
| 构造方法的特点 | 4 |
| 成员变量与局部变量的区别 | 4 |
| static 的特点 | 4 |
| 重写与重载 | 5 |
| 上转型对象 | 5 |
| 抽象类与接口 | 6 |
| try-catch-finally 执行顺序、throw/throws | 7 |
String 与 StringBuffer、== 与 equals | 8 |
| 字节流与字符流 | 10 |
| 线程创建方式、同步的必要性 | 12 |
| TCP 与 UDP | 13 |
| ArrayList 与 LinkedList、HashSet 去重、List/Set/Map | 15 |