文本描述
1.类A,B和C的定义如下:public class A {public void f() {System.out.println(“A.f()”);}}public class B extends A {public void
f() {System.out.println(“B.f()”);}}public class C {public void g(A a) {System.out.println(“g(A a)”);
a.f();}public void g(B b)
{System.out.println(“g(B b)”);b.f();}
}运行下面程序:C c = new C();A a = new B();c.g(a);输出的结果是:()。A. g(A a)A.f()B. g(A a)B.f()C.
g(B b)A.f()D. g(B b)B.f()正确答案:B2.执行下列语句:int a = 0x9af700; //1001 1010 1111 0111 0000 0000a <<= 2;变量a的值为:()。A.
0x26bdc00B. 0xc6bdc00C. 0x3fa0000D. 0x7e02ffff
正确答案:A3.下列代码的输出结果是()。int j=0;for(int i=0;i<100;i++)
{j=j++;}System.out.println(j);A.0B.99C.100D.101
正确答案:A4.请看下列代码:public static void main(String[] args) {< 插入代码>set.add(new
Integer(2));set.add(new Integer(1));System.out.println(set);}如果想保证程序的输出结果是[1,2],那么<插入代码>处应填入的代码是()。A.Set set = new
TreeSet();B.Set set = new HashSet();C.Set set = new SortedSet();D.Set set = new LinkedHashSet();正确答案:A5.列代码的运行结果是()。public class
Forest implements Serializable {private Tree tree = new Tree();public static void main(String[] args) {Forest f = new Forest();try {FileOutputStream fs
= new FileOutputStream(“Forest.ser”);Ob。。。。。。以下内容略