1. throw与throws的区别
throw:
- 创建一个异常
- 在方法内部使用,后面跟异常对象
- throw只能跟一个异常对象
throw new ArithmeticException("除数不能为0");
throws:
- 处理异常的一种方式,声明异常,让别人处理异常
- throws放在方法参数后面,后面跟异常类名
- throws后面可以跟多个异常类名
public static void main(String[] args) throws Exception { }
2. 为什么wait()和notify()方法放在Object类中
wait()和notify()使用锁对象调用,而任何对象都可以作为锁,所以这两个方法就放在 Object 类中
3.Location需要与状态码302配合使用,完成页面转发,这句话是否正确?
不正确,应该是重定向
JavaScript类
- 多选题:页面上只有如下一个标签,通过js给此标签设置背景色的代码正确的为( )
<input type=“text” name=“username” id=“username” />
A: document.getElementById(“username”).style.backgroundColor=“#ff0”
B: document.getElementByTagName(“input”).style.backgroundColor=“#ff0”
C: document.getElementsByName(“username”)[0].style.backgroundColor=“#ff0”
D: document.getElementsByTagName(“input”)[0].style.backgroundColor=“#ff0”
答案:ACD
tips:getElementByTagName(“input”)方法:取得相同标签内文本框内容
- 多选题:以下代码在页面加载后就能触发函数执行的有:( )
注:init方法已经提供
A: <script type=“text/javascript”> window.οnlοad=function(){} </script>
B: <body οnlοad=“init”></body>
C: <body οnlοad=“init()”></body>
D: <script type=“text/javascript”> οnlοad=function(){} </script>
E: <script type=“text/javascript”> function onload(){} </script>
答案:ACD