# 異常選擇題
**題目一**
下面哪個不對
1.
RuntimeException is the superclass of those exceptions that must be thrown during the normal operation of the JVM
1.
A method is not required to declare in its throws clause any subclasses of RuntimeExeption that might be thrown during the execution of the method but not caught.
1.
An RuntimeException is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch.
1.
NullPointerException is one kind of RuntimeException
答案是 3
RuntimeException an unchecked exception. It doesn't need to be explicitly declared or catched.
**題目二**
特殊情況就是里面加 return
舉個例子去理解
~~~
public int getNumber() {
int a = 0;
try {
String s = "t"; ------------------------(1)
a = Integer.parseInt(s);-----------(2)
return a;
} catch (NumberFormatException e) {
a = 1;-----------------------------------(3)
return a;-------------------------------(4)
} finally {
a = 2;-----------------------------------(5)
}
}
~~~
1、程序中標記的代碼的執行順序?2、改程序的最后返回值(外部調用時)?
程序按順序從上到下執行到(2),字符"t"轉換成整數失敗,產生異常并被捕獲,于是對a賦值成1,并將此值作為此方法的返回值(可以這么認為,該方法有一個存放返回值的空間,此時將1放在此處).由于存在finally塊,在返回前將該方法的內部變量a修改成2.所以程序將按標記的順序執行,外部調用該方法時得到的結果是1
先執行try或catch里里面的代碼,然后再執行finally,再執行try或catch里面的return.
**題目三**
寫出你最常見到的5個runtime exception
ClassCastExceptionIllegalArgumentExceptionNullPointerExceptionIndexOutOfBoundsExceptionArrayIndexOutOfBoundsException
**題目四**
- 介紹
- Java 基礎
- 請說一說 Java
- Java 為什么是高效的?
- 列舉出2個 IDE
- 面向對象的特征有哪些方面
- JDK JRE JVM
- 什么是對象 (Object)?
- 一個類是由哪些變量構成的
- 靜態變量和實例變量的區別?
- 封裝 Encapsulation
- 多態 Polymorphism
- 構造器是否可以被 override
- 接口 Interface 與抽象 abstract
- 接口和抽象的區別
- 基礎概念題
- 基礎程序題
- super 關鍵詞
- super 程序題
- this 程序題
- 抽象 abstract
- abstract 相關問題
- this() 和 super() 在構造體里怎么用?
- Static 關鍵字
- 一個static方法內部調用非static方法?
- Singleton 單例模式
- hashcode 和 equal
- == 和 equal 的區別
- 所有類的基類是哪個類?
- Java 支持多繼承嗎?
- Path 與 Classpath?
- 反射機制
- final 關鍵字
- 一個. java 源文件是否可以包含多個類
- & 與 &&
- int 與 integer
- integer 通過 == 比較
- 作用域的區別
- 異常
- error 和 exception?
- Checked 異常與 Runtime 異常
- 異常概念題
- 把對象聲明成異常
- 處理異常的方法
- 每一個 try 都必須有一個 catch 嗎?
- try 模塊里的 return
- final, finally, finalize的區別
- Programme
- 輸出問題1
- Gabage Collection
- heap 和 stack
- GC 就一定能保證內存不溢出嗎?
- 字節流與字符流
- Connection
- ArrayList 和 Vector
- HashMap 和 Hashtable
- HashMap HashTable LinkedHashMap TreeMap
- Connection 相關問題
- Multi-Thread
- sleep() 和 wait() 的區別
- 同步 synchronized
- 如何實現 muliti-thread?
- Transient 關鍵字
- preemptive scheduling 和 time slicing?
- 一個線程的初始狀態是什么?
- synchronized method 和 synchronized statement?
- 守護線程 daemon thread?
- 所有的線程都必須實現哪個方法?
- Visitor Pattern
- Problem on chain
- 字符串基礎問題
- StringBuffer 相關問題
- 數組相關問題
- 序列化 serialization
- 如何序列化一個對象到一個文件?
- 必須實現 Serializable 接口的哪個方法?
- 如何控制 serialization 的過程?
- 什么情況下要使用序列化?
- Externalizable 接口?
- 序列化時引用的處理?
- 序列化時要注意什么?
- 序列化時 static 域的處理?
- J2EE
- 什么是 J2EE?
- J2EE 應用的四個部分?
- What does application client module contain?
- What does web module contain?
- J2EE客戶端有哪些類型
- Hibernate是什么??
- 什么是事務 - transaction
- 什么是 servlet?
- 創建 servlet
- Servlet 必須實現什么接口?
- Servlet 生命周期?
- JSP
- JSP 的生命周期?
- JSP 語法
- JSP Actions?
- JSP translation?
- Ear, Jar 和 War 文件?
- URI 和 URL?
- DAO
- Spring
- 什么是 Spring?
- 使用 spring 的好處?
- Spring 都有哪些模塊?
- 什么是 Spring 的配置文件?
- 什么是依賴注入 - Dependency Injection?
- IoC 的類型?
- 你更傾向于哪種 DI
- IoC 有什么好處?
- IoC container 是什么?
- IoC 容器的類型?
- ApplicationContext 的實現都有哪些?
- Bean Factory 與 ApplicationContext ?
- 什么是 bean?
- 都有哪些 bean scope?
- Singleton bean 是線程安全的嗎?
- 說下 Bean 的生命周期
- 什么是基于注釋的容器配置?
- 如何注入 Java Collection?
- 什么是自動裝配
- 什么是 AOP?
- 通知的類型?
- Join point?
- Pointcut?
- Introduction?
- How do you provide configuration metadata to the Spring Container?
- How do add a bean in spring application?
- Can you inject null and empty string values in Spring?
- @Autowired @Inject @Resource
- Hibernate
- get and load
- 什么是 SessionFactory?
- SessionFactory 是線程安全的嗎?
- 什么是 Session?
- sorted 與 ordered collection
- What is the file extension used for hibernate mapping file?
- hibernate 的三種狀態
- Linux
- 查找文件
- 列出文件列表
- 設計一對一
- 設計一對多
- 設計多對多
- 都使用過哪些join?
- inner join
- Left/Right join
- Full join
- 合并的問題
- Union all?
- Where 和 Having
- 通配符 wildcard?
- Scrum
- Scrum 中的三大角色
- What's sprint?
- How to scrum
- Continuous integration
- Statement 和 prepared statement?
- Callable statement
- Stored Procedure and how do you call it in JDBC?
- What does the Class.forName("MyClass") do?
- Connection Pooling ?
- What are the steps in the JDBC connection?