请教各位几道JAVA试题!希望大家帮忙!
1、Refer的类层次结构,如下图所示。
动物
狗 猫 .....
Consider the following code:
1. Dog rover, fido;
2. Animal anim;
4. rover = new Dog();
5. anim = rover;
6. fido = (Dog)anim;
Which of the following statements is true? (Choose one.) My answer is D
A. Line 5 will not compile.
B. Line 6 will not compile.
C. The code will compile but will throw an exception at line 6.
D. The code will compile and run.
E. The code will compile and run, but the cast in line 6 is not required and can be eliminated.
2、请说出如下几个类的特性 并说明Collection 和 Collections的区别?
a) java.util.ArrayList
b) java.util.HashSet
c) java.util.TreeSet
d) java.util.HashMap HashMap和Hashtable的区别
3、一个JSP页面传递了一个request对象名字"test" 该页面使用标签
<bean:write name="test" property="info.value">
请说明显示的内容来自于哪里?
My answer :Test 对象内关联的 info对象的 value值
4、编写程序 带2个输入参数 起始值 最大值
比如 输出1-100的质数 (质数:只能被自己和1整除的自然数)