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整除的自然数)

解决方案 »

  1.   

    1.编译后能够正常运行
    2.不是很懂,List和Set是集合类,List可以有重复元素,Set中不可以;Map是映射,key-value
    3.test对象中的info对象的value属性,getInfo().getValue();
    4.自己写吧
      

  2.   

    1.明白向下转型是不安全的!
    2.Collection是集合类,Collections是工具类。
       A.Arraylist查询效率高,增删效率低,线程不安全类
       B.HashSet是散列集,即不重复元素
       C.TreeSet除不重复元素外,即有自动排序功能,效率较低。
       D.区别多的去了,HashTable线程安全,HashMap不是,HashTable不允许null值(key和value都不可  以),HashMap允许null值。这只是些表面的!其他还有很多!
    3.来自哪里?没清楚,但:name是要进行显示的bean的名称,而porterty是要显示的属性名称。在没有指定scope时候,会从小范围到大范围的查找。
    4.作业自己写!
      

  3.   

    第四题:
    public static void zhizhu(int x, int y) {
    for (int i = x; i <= y; i++) {
    int k = 2;
    for (; k < i; k++) {
    if (i % k == 0)
    break;
    }
    if (k == i || i == 1)
    System.out.print(i + " ");
    }
    }