Checked Exception And Runtime exception

今天去一家小公司面试的时候看到一道题

 

反正就是关于函数声明为抛出RuntimeException的子类

 

这个时候对该方法的使用,不需要加上try catch保证的。

 

/**
 * 
 */
package com.zuzu.exception;

/**
 * @author chunfeng.zhu
 * @mailto:[email protected]
 * 
 */
public class TestException {

	/**
	 * 
	 */
	public TestException() {
		// TODO Auto-generated constructor stub
	}

	public void testException() throws OwnException {
		int i = 9 / 0;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		TestException exception = new TestException();
		exception.testException();
	}

	public class OwnException extends RuntimeException {
		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;

	}

}

 

你可能感兴趣的:(面试,Gmail)