1、1. 下面程序的运行结果是( ) 。public class E3public static void main(String args)String s=“大大“;char a=s.charAt(2),b=s.charAt(4);System.out.print(a);System.out.println(b);2. 下面程序的运行结果是( ) 。import java.util.*;public class LinkedListExample public static void main(String args)LinkedList linkedlist = new LinkedList
2、(); linkedlist.add(new Integer(1);linkedlist.add(new Integer(2);linkedlist.add(new Integer(3);linkedlist.add(new Integer(4);linkedlist.add(new Integer(5);System.out.println(“The original contents of the linkedlist is: “);System.out.println(linkedlist);linkedlist.add(2,“hello“); linkedlist.addFirst(“
3、First“); linkedlist.addLast(“Last“); System.out.println(“After adding elements,the linkedlist is: “);System.out.println(linkedlist);答:3. 下面程序的运行结果是( )。public class TestArray public static void main(String args) int i, j;int a = 5, 9, 6, 8, 7 ;for (i = 0; i = a z=情; else y=我;z=她;System.out.println(“
4、“+x+y+z);19. 下面程序的运行结果是( ) 。class TT public TT() System.out.println(“What a peasure!“);public TT(String s) this();System.out.println(“I am “ + s);public class Example extends TT public static void main(String args) Example example = new Example();public Example(String s) super(s);System.out.println(
5、“How do youo do?“);public Example() this(“I am Tom“);20. 下面程序的运行结果是( ) 。public class Example public static void main(String args) int count = 0;for (int i = 0; i 3; i+) resume:for (int j = 0; j 4; j+) for (int k = 0; k 5; k+) +count;if (i = 1 System.out.println(“tcount=“ + count);21. 下面程序的运行结果是( ) 。
6、public class A class Dog private String name;private int age;public int step;Dog(String s, int a)name = s;age = a;step = 0;public void run(Dog fast)fast.step-;public static void main(String args)A a = new A();Dog dog = a.new Dog(“Tom“, 3);dog.step = 30;dog.run(dog);System.out.println(dog.step);22. 下
7、面程序的运行结果是( ) 。import java.io.*;public class TestFile public static void main(String args) throws Exception BufferedReader br = new BufferedReader(new InputStreamReader(System.in);BufferedWriter bw = new BufferedWriter(new FileWriter(“input.txt“);String s;while (true) System.out.print(“请输入一个字符串: “);S
8、ystem.out.flush();s = br.readLine();if (s.length() = 0)break;bw.write(s);bw.newLine();bw.close();23. 下面程序的运行结果是( ) 。class A public String Show(D obj) return (“A and D“); public String Show(A obj) return (“A and A“); class B extends A public String Show(B obj) return (“B and B“); public String Show(A
9、 obj) return (“B and A“); class C extends B public String Show(C obj) return (“C and C“); public String Show(B obj) return (“C and B“); class D extends B public String Show(D obj) return (“D and D“); public String Show(B obj) return (“D and B“); public class main public static void main(String args)A a1 = new A();A a2 = new B();B b = new B();C c = new C();D d = new D();System.out.println(a1.Show(b); System.out.println(a1.Show(c);