查看完整版本: SCJP 天天做

非常菜 2007-6-23 20:36

SCJP 天天做

[size=2]首先,开这帖的灵感来自于论坛[color=blue]赵高[/color]兄,他在“思科认证区”的《CCNA日日做》相当好,首先把英文的题目翻译成了中文,对于英语水平不是很好的朋友,也有了学习,交流的场所。其次,除了原题的解答,加上自己的理解,通过题目,达到对知识点,考点的更深刻理解,也有助于更好地掌握技术。[/size]
[size=2][/size]
[size=2]我刚在前两天通过SCJP,有感于SCJP资源的缺乏(相对思科、微软等认证的资料),题库的诸多错误,加上为了活跃“其他认证区”,于是也萌生了开一个“SCJP天天做”的主题。目的是为了给广大要考SCJP认证的朋友提供一个学习,交流,提问,讨论的场所。[/size]
[size=2][/size]
[size=2]我是这么打算的:题目以[b][color=darkgreen]Actualtests 310-055 02.01.07 180题[/color][/b]版为主,因为这个版本是目前310-055考试最新的版本(论坛FTP3 有下载)。[/size]
[size=2][/size]
[size=2][color=blue][b]也欢迎要报考310-035的朋友把你们想要分享、提问的题目发出来[/b][/color],大家一起看,一起学,一起提高![/size]
[size=2][/size]
[size=2]只要我有时间,每天2道题,争取3~4个月时间全部更新完。[/size]
[size=2][/size]
[size=2]因为我本人才学有限,SCJP虽然通过,但是分数并不是很高,有一些问题,我也不能回答很准确,不当之处,还请大家多多谅解,但我一定会努力。同时,也希望大家不要有顾忌,把自己的不同意见说出来,争取把所有的知识点都讨论得更透彻,把知识掌握得更牢固![/size]
[size=2][/size]
[size=2][color=blue][b]所有有关问题的发言,无论正确与否,我都将给与1~10分的奖励![/b][/color][/size]
[b][size=2][color=#0000ff][/color][/size][/b]
[b][size=2][color=darkgreen]题库大家也可以参照附件中的,题目基本一样,只不过这个版本老些,答案更少些[/color][/size][/b]

[[i] 本帖最后由 非常菜 于 2007-6-26 12:13 编辑 [/i]]

非常菜 2007-6-23 20:40

Q1 & Q2

[size=2]QUESTION 1[/size]
[attach]176456[/attach]
[size=2]Given the code in the exhibit.
What is the result?
A. Compilation fails
B. An exception is thrown at runtime.
C. An instance of Forest is serialized.
D. An instance of Forest and an instance of Tree are both serialized.
Answer: B[/size]
[size=2][/size]
[size=2][color=blue][b]解释:B正确[/b][/color][/size]
[size=2][/size]
[size=2]首先,请注意,原题中[b][color=darkorange]第[color=darkorange]19行[/color][/color][color=darkorange]是错误的[/color][/b]实例化ObjectOutputStream怎么能用FileOutputStream的构造函数呢?[/size]
[size=2]如果按照原题,毫无疑问,肯定是选A,编译失败。我们现在假定这里写错了。[/size]
[size=2][/size]
[size=2]这道题考查的是aggregation(复合)在串行化中的使用问题。要注意的是,在串行化实现类中所有aggregation类,即用new Class()实例化的那些类也必须是可串行化的。在本程序中,对Tree类进行了实例化,而这里的Tree类没有实现Serializable接口,即Tree类不可串行化。因此就会抛出异常,请注意,这里抛出的是Runtime Exception(运行期异常),真正抛出的是NotSerializableException运行期异常,就是说,该程序在编译时将会通过,只有在运行时会抛出异常。[/size][code]import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;

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");
                        ObjectOutputStream os = new ObjectOutputStream(fs);
                        os.writeObject(f);
                        os.close();
                } catch (IOException e) {
                        e.printStackTrace();
                }
        }
}

class Tree {}[/code][size=2][color=blue][b]代码:[/b][/color][/size][size=2][color=blue][b]输出:[/b][/color][/size][code]java.io.NotSerializableException: Tree
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeObject(Unknown Source)
at Forest.main(Forest.java:13)[/code][size=2][/size]
[size=2][/size]
QUESTION 2
[attach]176457[/attach]
Which code, inserted ay line 14, will allow this class to correctly serialized and
desterilize?
A. S. default ReadObject ();
B. This = s.defaultReadObject ();
C. Y = s.default (); x = s.readInt ();
D. X = s.readlInt; y = s.readInt ();
Answer: D

[size=2][color=blue][b]解释:D正确[/b][/color][/size]
[b][size=2][color=#0000ff][/color][/size][/b]
[size=2][color=#000000]题目问,如何使该类正确串行化和反串行化。首先,ObjectOutputStream中没有default()这个方法,因此C可以排除,而在JDK文档中关于defaultReadObject是这么用的:[/color][/size][code]defaultReadObjectpublic void defaultReadObject()
                       throws IOException,
                              ClassNotFoundException

Read the non-static and non-transient fields of the current class from this stream. This may only be called from the readObject method of the class being deserialized. It will throw the NotActiveException if it is called otherwise.

Throws:
ClassNotFoundException - if the class of a serialized object could not be found.
IOException - if an I/O error occurs.
NotActiveException - if the stream is not currently reading objects.[/code][size=2][b][color=#0000ff]请注意,无返回值[/color][/b][color=#000000],而且也没有this = ...这种用法,B也可以被排除。而这里其实真正要做的是反串行化。注意到在串行化过程中有writeInt操作,那么在反串行化过程中,就应该是readInt操作。[/color][/size]
[size=2][color=#000000]在这里,再请注意,[color=blue][b]串行化写入顺序为x,y,读出到时候也要x = s.readInt(); y = s.readInt();[/b][/color]这个顺序一定要注意。[/color][/size]
[size=2][color=#000000][/color][/size]
[size=2][color=blue][b]代码:[/b][/color][/size][code]import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;

public class Foo implements Serializable {
        /**
         *
         */
        private static final long serialVersionUID = -2633363360024255552L;
        private int x, y;
        
        public Foo(int x, int y) {
                this.x = x;
                this.y = y;
        }
        
        public static void main(String[] args) {
                Foo f = new Foo(1, 2);
                try {
                        FileOutputStream fos = new FileOutputStream("Foo.txt");
                        ObjectOutputStream oos = new ObjectOutputStream(fos);
                        f.writeObject(oos);
                        oos.close();
                } catch (FileNotFoundException e) {
                        e.printStackTrace();
                } catch (IOException e) {
                        e.printStackTrace();
                }
                try {
                        FileInputStream fis = new FileInputStream("Foo.txt");
                        ObjectInputStream ois = new ObjectInputStream(fis);
                        f.readObject(ois);
                        ois.close();
                        System.out.println(f.getX());
                        System.out.println(f.getY());
                } catch (FileNotFoundException e) {
                        e.printStackTrace();
                } catch (IOException e) {
                        e.printStackTrace();
                } catch (ClassNotFoundException e) {
                        e.printStackTrace();
                }
        }
        
        private void writeObject(ObjectOutputStream s) throws IOException {
                s.writeInt(x);
                s.writeInt(y);
        }
        
        private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {
                x = s.readInt(); // 第55行
                y = s.readInt(); // 第56行
        }

        public int getX() {
                return x;
        }

        public void setX(int x) {
                this.x = x;
        }

        public int getY() {
                return y;
        }

        public void setY(int y) {
                this.y = y;
        }
}[/code][size=2][color=#000000][/color][/size]
[size=2][color=blue][b]输出:[/b][/color][/size]
[color=black][code]1
2[/code][/color]
[size=2][color=#000000]如果把代码中第55行和56行的位置互换,即这里x = s.readInt(); y = s.readInt();换一下顺序的话,输出结果就变成:2 1了,即x = 2; y = 1;这当然与我们希望的不符了。因此,请千万注意这里的串行化和反串行化时的代码。[/color][/size]

[[i] 本帖最后由 非常菜 于 2007-6-24 13:59 编辑 [/i]]

jiya0011 2007-6-23 22:50

:loveliness: :loveliness: :loveliness:
支持非常菜同学

xiazaikuang 2007-6-24 00:52

马上就要考试了,,,,,scjp

zqz 2007-6-24 12:06

支持楼主,只是有的东西我看不到,哈哈,新来的

非常菜 2007-6-24 13:16

Q3 & Q4

QUESTION 3
Given the exhibit.
[attach]176903[/attach]
What is the result?
A. 0
B. 1
C. 4
D. Compilation fails
E. An exception is thrown at runtime
Answer: D

[size=2][color=blue][b]解释:[/b][color=black]答案D[/color][/color][/size]
[size=2][/size]
[size=2]这道题考查的是正则表达式。错误出现在第12行代码。这里要注意的是在双引号中的“\”是转义字符,编译器会其他“\”后的正确转义元字符,但是后面是一个“s”。而“\s”没有这个转义字符,于是编译器报错。这里正确的用法是“\\s”,[color=blue][b]第一个“\”告诉编译器,接下来的字符请取字面量[/b][/color],而不是转义转义字符。随后出现的[color=blue][b]\s表示空白字符[/b][/color][color=black],类似的元字符还有:\d(数字)、\w(字字符,字母、数字等)[/color]
及.元字符。[/size]
[size=2][/size]
[b][size=2][color=blue]代码:[/color][/size][/b][code]public class Test {
        public static void main(String args[]) {
                String test = "This is a test";
                String[] token = test.split("\s");
                System.out.println(token.length);
        }
}[/code][size=2][/size]
[size=2][color=blue][b]输出:[/b][/color][/size][code]Exception in thread "main" java.lang.Error: 无法解析的编译问题:
        转义序列无效(有效值为 \b  \t  \n  \f  \r  \"  \'  \\)

        at Test.main(Test.java:4)[/code]QUESTION 4
Given the exhibit:
[attach]176904[/attach]
The variable df is an object of type DateFormat that has been initialized in line 11.
What is the result if this code is run on December 14,2000?
A. The value of S is 14 - dic-2004
B. The value of S is Dec 14, 2000
C. An exception is thrown at runtime
D. Compilation fails because of an error in line 13.
Answer: D

[size=2][color=blue][b]解释:[/b][/color]答案D[/size]
[size=2][/size]
[size=2]这道题考点是日期相关类的格式化,如果熟悉API,那这很明显是第13行错误,因为[color=blue][b]根本没有setLocale()方法[/b][/color]。以下代码为Date、DateFormat、Locale类的正确用法:[/size]
[size=2][/size]
[size=2][color=blue][b]代码:[/b][/color][/size][code]import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;

public class Test {
        public static void main(String args[]) {
                Date date = new Date();
                Locale loc = new Locale("it", "IT");
                DateFormat df = DateFormat.getDateInstance(DateFormat.FULL, loc);
                String s = df.format(date);
                System.out.println(s);
        }
}[/code][size=2][color=blue][b]输出:[/b][/color][/size][code]domenica 24 giugno 2007[/code]

[[i] 本帖最后由 非常菜 于 2007-6-26 13:54 编辑 [/i]]

非常菜 2007-6-25 09:35

Q5 & Q6

QUESTION 5
The doesFileExist method takes an array of directory names representing a path
from the root filesystem and a file name. The method returns true if the file exists,
falst if does not.
Place the code fragments in position to complete this method.
[attach]177089[/attach]

[size=2][color=blue][b]解释:[/b][/color][/size]

[size=2][color=blue][b]代码:[/b][/color][/size][code]import java.io.File;

public class Test {
        public static void main(String args[]) {
                Test t = new Test();
                String[] dir = {"workspace", "Practice", "bin", "utils"};
                String name = "test.txt";
                System.out.println(t.doesFileExist(dir, name));
        }
        
        public boolean doesFileExist(String[] directories, String fileName) {
                String path = "";
               
                for (String dir : directories) {
                        path = path + File.separator + dir; // 第15行
                }
                File file = new File(path, fileName);
                return file.exists();
        }
}[/code][size=2]如代码所示,我有一个“test.txt”文件放在“D:\workspace\Practice\bin\utils\”目录下,如上代码,则可以返回true。[color=blue][b]这里要注意第15行,现在,编译器看到的是:“\workspace\Practice\bin\utils”。[/b][/color][color=#000000]第一个“\”表示[b][color=blue]根目录[/color][/b],如果没有这个“\”,比如“workspace\Practice\bin\utils”则表示[color=blue][b]当前目录[/b][/color]下的“workspace\Practice\bin\utils”子目录。题目给出的范例代码是有问题的,问题出在“d[0] = "C:"”这行。现在能理解了吧,如果按照他这样写,编译器看到的是“\C:”这个路径,显然没有这样的路径。[/color][/size]

QUESTION 6
Given:
System.out.printf("Pi is approximately %f and E is approximately %b", Math.PI,
Math.E);
Place the values where they would appear in the output.
[attach]177090[/attach]

[b][size=2][color=blue]答案:依次为 3.141593、true[/color][/size][/b]

[size=2][color=blue][b]解释:[/b][/color][/size]
[size=2][color=#000000]这里的考点是格式化,“%f”参数为浮点型,“%b”参数为布尔型。[i]Math.PI[/i]常量本为double型的,现在要浮点输出,[color=blue][b]多余部分将四舍五入,而非截断[/b][/color]。Math.E常量也是double型的,现在要以布尔型输出,这里[color=blue][b]不管>0、<=0还是==0都是true,只有在变量为null或者为boolean、Boolean型,并值为false时,输出才是false[/b][/color]。[/color][/size]

[size=2][color=blue][b]代码:[/b][/color][/size][code]public class Test {
        public static void main(String args[]) {
                System.out.printf("Pi is approximately %f and E is approximately %b",
                                Math.PI, Math.E);
        }
}[/code][size=2][b][color=blue]输出:[/color][/b][/size][code]Pi is approximately 3.141593 and E is approximately true[/code]

[[i] 本帖最后由 非常菜 于 2007-6-25 11:35 编辑 [/i]]

非常菜 2007-6-26 12:15

Q7 & Q8

QUESTION 7
When comparing java. Io. BufferedWriter to java.io.FileWriter, which capability
exist as a method in only one of the two?
A. closing the stream
B. flushing the stream
C. writing to the stream
D. marking a location in the stream
E. writing a line separator to the stream

Answer: E

[size=2][b][color=blue]解释:[/color][/b]答案E 没有问题

这道题没有什么技术含量,考查的是BufferedWriter类和FileWriter类中方法的异同,查一下API doc就OK了。

这里要注意的是,close()、flush()和write()方法是这两个类都有的,就是ABC三个选项,而D选项所描述的方法这两个类都没有,E选项说的是[color=blue][b]newLine()方法,该方法仅BufferedWriter在类中提供[/b][/color]。[/size]
[size=2][/size]

QUESTION 8
Given the exhibit:
[attach]177175[/attach]
Which two code fragments, inserted independently at line 3, generate the output
4247? (choose two)
A. String s = "123456789"
S. = (s-"123").replace (1,3, "24") - "89";
B. StringBuffer s = new StringBuffer ("123456789");
S.delete (0,3) replace(1,3,"24"). Delete (4,6)
C. StringBuffer s = new StringBuffer ("123456789");
S.substring (3,6).delete(1,3). insert (1, "24").
D. StringBuilder s \= new StringBuilder ("123456789");
S.substring (3,6) delete (1,2). insert (1, "24")
E. StringBuilder s = new StringBuilder ("123456789");
S.delete (0,3) replace(1,3,). Delete (2,5) insert (1, "24")

Answer: B,E

[size=2][color=blue][b]解释:[/b][/color]答案BE 没有问题[/size]
[size=2][/size]
[size=2]这道题考查的是String、StringBuffer和StringBuilder类中replace()、delete()、substring()和insert()等方法的应用。[/size]
[size=2][/size]
[size=2]StringBuffer和StringBuilder这两个类,除了[b][color=blue]前者是线程安全,后者虽然不是线程安全,但是效率比前者高之外,这两个类完全相同[/color][/b]。自然,他们的方法也都相同。[/size]
[size=2][/size]
[size=2]要注意的是,这几个方法中的的前两个参数,第一个参数表示的是在字符串中取的起始字符,是字符在字符串中[color=blue][b]从“0”开始的index索引[/b][/color];而第二个参数表示的是字符串中取字符的终止位置,是[color=blue][b]从“1”开始的字符在字符串中的位置[/b][/color]。下面我们就一个选项一个选项地来分析:[/size]
[size=2][/size]
[size=2]A String没有s-""这种用法,所以错误。[/size]
[size=2][/size]
[size=2]B s.delete(0, 3)后,s = "456789",.replace(1, 3, "24")后,s = "424789",.delete(4, 6)后,s = "4247"。正确。[/size]
[size=2][/size]
[size=2]C和D 这里要注意,在使用了StringBuffer(StringBuilder).substring()方法后,[color=blue][b]返回的是String的变量[/b][/color]了,而String类中没有定义delete()方法,所以CD必然编译失败。[/size]
[size=2][/size]
[size=2]E s.delete(0, 3)后,s = "456789",[color=darkgreen][b].replace(1, 3, )[/b][/color]([color=blue][b]注意,如果按照选项中第三个参数为空这样的写法,将引起编译错误,为了契合答案,这里改成[color=darkgreen].replace(1, 3, "")[/color]就没有问题了,替换为空字符串完全合法[/b][/color])后,s = "4789",.delete(2, 5)(虽然[color=blue][b]第二个参数“5”超出了字符串中字符个数范围,但是合法[/b][/color])后,s = "47" ,insert(1, "24")后,s = "4247"。正确。"4247"。[/size]
[size=2][/size]
[size=2][color=blue][b]代码:[/b][/color][/size][code]public class Test extends Thread {

        
        public static void main(String args[]) {
//                String s = "123456789";
                StringBuffer s = new StringBuffer("123456789");
//                StringBuilder s = new StringBuilder("123456789");
               
//                s = (s-"123").replace (1,3, "24") - "89"; // A
//                s.delete (0,3).replace(1,3,"24").delete(4,6); // B
//                s.substring(3,6).delete(1,3).insert (1, "24"); // C
//                s.substring(3,6).delete(1,2).insert(1, "24"); // D
                s.delete(0, 3).replace(1, 3, "").delete(2, 5).insert(1, "24"); // E
                System.out.println(s);
        }
}[/code]

[size=2][color=blue][b]输出:[/b][/color][/size]
[code]4247[/code]

[[i] 本帖最后由 非常菜 于 2007-6-26 13:53 编辑 [/i]]

非常菜 2007-6-27 09:00

Q9 & Q10

QUESTION 9
Which three statements concerning the use of the java . io. [color=blue]Realizable(疑为笔误,应为Serializable)[/color] interface are
true? (choose three)
A. Object from classes that use aggregation cannot be serialized.
B. An object serialized on one JVM can be successfully desterilized on a different JVM.
C. The values in fields with the Volatile modifier will NOT survive serialization and
deserialization
D. The values in field with the transient modifier will NOT survive serialization and
deserialization
E. It is legal to serialize an object of a type that has a supertype that does NOT implement
java .io.Serialization

Answer: B,D,E

[size=2][color=black][b][color=blue]解释:[/color][/b]答案BDE[/color][/size]
[size=2][color=black][/color][/size]
[size=2][color=black]这道题很明显考查的是串行化的知识。[/color][/size]
[size=2][color=black][/color][/size]
[size=2][color=black]B 一次编译到处运行正式java的最大特点和魅力所在,当然可以运行在其他JVM,比如在windows下串行化,在Linux下反串行化;[/color][/size]
[size=2][color=black]D 使用transient关键字的一个重要作用就是在串行化的时候跳过这个带transient的字段;[/color][/size]
[size=2][color=black]E 串行化一个其超类没有实现串行化类的子类是完全合法的,而且也是合适的。[/color][/size]
[size=2][color=black][/color][/size]
[size=2][color=black]A 错误在于,使用复合产生的类的对象也是可以被串行化的,只要这个类实现了Serializable;[/color][/size]
[size=2][color=black]C 错误在于volatile不影响串行化。
[/color][/size]

QUESTION 10
Given the exhibit:
[attach]177249[/attach]
What is the result?
A. short Long
B. SHORT LONG
C. Compilation fails
D. An exception is thrown at runtime

Answer: C

[size=2][b][color=blue]解释:[/color][/b]答案C[/size]
[size=2][/size]
[size=2]这道题考查的是包装类的包装与加宽问题。这道题引起编译失败的原因在于go(z);方法,这里z是int型变量,无法符合go(short)和go(Short)参数方法,只能尝试go(Long)方法,他首先需要加宽到long,再包装成Long类型,但是[b][color=blue]不能先加宽,再装箱[/color][/b]!所以,引起了错误。如果先装箱再加宽是可以的,int先装箱成Integer,再加宽到Number或者Object,但是这里也[color=blue][b]不能Integer-->Long[/b][/color],注意,[color=blue][b]包装类都是平级的[/b][/color]![/size]
[size=2][/size]
[size=2][color=blue][b]代码:[/b][/color][/size][code]public class Test extends Thread {
        public static void main(String args[]) {
                Short y = 6;
                int z = 7;
               
                go(y);
                go(z);
        }
        
        public static void go(short n) {
                System.out.println("short");
        }
        
        public static void go(Short n) {
                System.out.println("SHORT");
        }
        
        public static void go(Long n) {
                System.out.println("LONG");
        }
}[/code][size=2][color=blue][b]输出:[/b][/color][/size][code]Exception in thread "main" java.lang.Error: 无法解析的编译问题:
        类型 Test 中的方法 go(short)对于参数(int)不适用

        at Test.main(Test.java:7)[/code]

[[i] 本帖最后由 非常菜 于 2007-6-27 09:23 编辑 [/i]]

非常菜 2007-6-28 14:46

Q11 & Q12

QUESTION 11
Given the exhibit:
* D is valid , non-null Dateobject
* df is a valid, non-null DateFormat object set to the current local
What outputs the current ; local's country name and the appropriate version of d's
date?
A. Local loc = Local.getLocal ( );
System.out printIn (loc.getDisplayCountry ( )
B. Local loc = Local.getDefault ( );
System.out printIn (loc.getDisplayCountry ( )
+ " " " +df. Format (d) );
C. Local loc = Local.getLocal ( );
System.out printIn (loc.getDisplayCountry ( )
+ " " +df. setDateFormat (d) );
D. Local loc = Local.getDefault ( );
System.out printIn (loc.getDisplayCountry ( )
+ " " +df.setDateFormat (d) );

Answer: B

[size=2][b][color=blue]解释:[/color][/b]答案B[/size]
[size=2][/size]
[size=2]这道题考查的是DateFormat类、Locale类的方法。要注意的是,没有getLocal()、setDateFormat()方法,对于Locale类,只有getDefault()和setDefault(Locale new Locale)方法。DateFormat类只有format()方法,而没有setDateFormat(Date d)方法。所以,只有B正确。
[/size]
QUESTION 12
Given the exhibit:
[attach]177359[/attach]
What is the result?
A. Compilation fails.
B. An exception is thrown at runtime
C. The code executes and prints " running"
D. The code executes and prints "runningrunning"
E. The code executes and prints "runningrunninigrunning

Answer: E

[size=2][color=blue][b]解释:[/b][/color]答案E[/size]
[size=2][/size]
[size=2]这道题考查的是线程和方法调用的区别。要注意第7行和第8行是Thread类的方法调用,该方法打印“running”。然后,运行线程,再打印“running”。[/size]

[size=2][color=blue][b]代码:[/b][/color][/size]
[code]public class Test implements Runnable {
        public static void main(String[] args) {
                Thread t = new Thread(new Test());
                t.run();
                t.run();
                t.start();
        }

        public void run() {
                System.out.print("running");
        }
}[/code]
[size=2][color=blue][b]输出:[/b][/color][/size]
[code]runningrunningrunning[/code]

[[i] 本帖最后由 非常菜 于 2007-6-28 15:00 编辑 [/i]]

非常菜 2007-6-29 11:16

Q13 & Q14

QUESTION 13
Exhibit:
[attach]177499[/attach]
Which two are possible results? (choose two)
A. 0,2,4,4,6,8,10,6,
B. 0,2,4,6,8,10,2,4,
C. 0,2,4,6,8,10,12,14,
D. 0,0,2,2,4,4,6,6,8,8,10,10,12,12,14,14,
E. 0,2,4,6,8,10,12,14,0,2,4,6,8,10,12,14,

Answer: A,C

[size=2][color=blue][b]解释:[/b][/color]答案AC[/size]

[size=2]这道题考查的是线程间和线程内运行的顺序问题。要注意的是,[b][color=blue]线程运行是没有保证的[/color][/b],就是说,可能一个线程运行完在运行另一个线程,也可能在一个线程运行期间运行另一个线程(解决这个问题的唯一办法就是synchronized关键字)。但是,[color=blue][b]一个线程内部的程序执行是有序的[/b][/color],比如累加,在一个线程内部,后一个数一定比前一个数大。所以,这里,我们这样看:[/size]
[size=2]A. [b][color=sienna]0,2,4,[/color][color=darkgreen]4,6,8,10,[/color][color=sienna]6,[/color][/b]
B. [color=sienna][b]0,2,4,6,[/b][/color]8,10,2,4,
C. [b][color=sienna]0,2,4,6,[/color][color=darkgreen]8,10,12,14,[/color][/b]
D. 0,0,2,2,4,4,6,6,8,8,10,10,12,12,14,14,
E. 0,2,4,6,8,10,12,14,0,2,4,6,8,10,12,14,
[/size]
[size=2]AC可以保证序列的有序执行,两种颜色区分。B,无论如何,2,4,都不会8,10,之后出现。DE的运行次数过多,不符合题意。[/size]

[b][size=2][color=blue]代码:[/color][/size][/b][code]public class Test {
        int x = 0;
        public class Runner implements Runnable {
                public void run() {
                        int current = 0;
                        for (int i = 0; i < 4; i++) {
                                current = x;
                                System.out.print(current + ",");
                                x = current + 2;
                        }
                }
        }
        
        public static void main(String[] args) {
                new Test().go();
        }

        public void go() {
                Runner r1 = new Runner();
                new Thread(r1).start();
                new Thread(r1).start();
        }
}[/code][b][size=2][color=blue]输出:
[/color][/size][/b][code]0,2,4,6,8,10,12,14,[/code]QUESTION 14
Given the exhibit:
[attach]177500[/attach]
Which statement is true?
A. This code may throw an InterruptedException
B. This code may throw an IllegalStateExcepion
C. This code may throw a TimeOutException after ten minutes
D. This code will not compile unless "obj.wait ( ) \" is replaced with " (( Thread) obj)
.wait ( )"
E. Reversing the order of obj.wait ( ) and obj. notify ( ) may vcause this method to
complete normally

Answer: B

[size=2][color=blue][b]解释:[/b][color=black]答案A?[/color][/color][/size]
[size=2][color=black][/color][/size]
[size=2][color=black]这道题,我是有疑惑的,我觉得是选A。这里考查的是Object类中有关线程的两个方法,要注意的是,wait()、sleep()和join()方法要声明异常[color=blue][b]InterruptedException[/b][/color](其中,后两个方法是Thread类中的方法)。很明显,[color=blue][b]wait()方法没有声明抛出异常或者用try/catch包围[/b][/color]。[/color][/size]
[size=2][color=#000000][/color][/size]
[size=2][color=blue][b]代码:[/b][/color][/size][code]public class Test {
        public static void main(String[] args) {
                new Test().waitForSignal();
        }
        
        void waitForSignal() {
                Object obj = new Object();
                synchronized(Thread.currentThread()) {
                        obj.wait();
                        obj.notify();
                }
        }
}[/code]

[size=2][color=blue][b]输出:[/b][/color][/size]

[code]Exception in thread "main" java.lang.Error: 无法解析的编译问题:
        未处理的异常类型 InterruptedException

        at Test.waitForSignal(Test.java:9)
        at Test.main(Test.java:3)[/code]

[[i] 本帖最后由 非常菜 于 2007-6-29 12:07 编辑 [/i]]

非常菜 2007-6-30 12:28

Q15 & Q16

QUESTION 15
Given the exhibit:
[attach]177562[/attach]
What can be a result?
A. Compilation fails
B. An exception is thrown at runtime
C. The code executes and prints "StartedComplete"
D. The code executes and prints "StartedComplete0123"
E. The code executes and prints "Started0123Complete"

Answer: E

[size=2][color=blue][b]解释:[/b][/color]答案E

这道题考查的是线程中join()方法的使用。[b][color=blue]join()方法将[color=darkgreen]当前线程放在调用join()方法的线程之后[/color]运行。[/color][/b]比如,这里,就是将main线程放在t线程之后运行,这样就保证了0~3这4个数字的输出,而不被main线程中的其他操作所打断。
[/size]
[b][size=2][color=blue]代码:[/color][/size][/b][code]public class Test implements Runnable {
        public static void main(String[] args) throws Exception{
                Thread t = new Thread(new Test());
                t.start();
                System.out.print("Started");
                t.join();
                System.out.print("Complete");
        }

        public void run() {
                for (int i = 0; i < 4; i++) {
                        System.out.print(i);
                }
        }
}[/code][b][size=2][color=blue]输出:[/color][/size][/b][code]Started0123Complete[/code]QUESTION 16
Which two code fragments will execute the method doStuff ( ) in a separate thread?
(choose two)
A. new Thread ( ) {
public void run ( ) { doStuff ( ); }
};
B. new Thread ( ) {
public void run ( ) { doStuff ( ); }
};
C. new Thread ( ) {
public void run ( ) { doStuff ( ); }
}; run ( );
D. new Thread ( ) {
public void run ( ) { doStuff ( ); }
}; start ( );
E. new Thread (new Runable ( ) {
public void run ( ) { doStuff ( ); }
}; run ( ) ;
F. new Thread (new Runnable ( ) {
public void run ( ) { doStuff ( ); }
}), start ( );

Answer: D,F

[size=2][color=blue][b]解释:[/b][/color]答案DF[/size]
[size=2][/size]
[size=2]这道题考查的是线程的定义,复写(override)和启动。要复写的方法是类Thread或接口Runnable中的run()方法,而启动的方法是start()。[/size]
[size=2]AB因为没有启动方法,因此无法运行该线程,CE的启动线程方法错了,不是run()而应该是start()。因此这里只有DF正确,代码不写了,这里考查的都是概念。另外,这里还融入了内部类的写法,也要加以注意。[/size]

othella 2007-6-30 13:54

写的真不错!学习中。。。:lol:

赵高 2007-6-30 18:46

看来Java比较难啊,没有一定基础看不懂。

非常菜 2007-7-1 11:19

Q17 & Q18

QUESTION 17
Which three will compile and run without exception? (choose three)
A. private synchronized object o;
B. void go ( ) {
synchronized ( ) { /* ocde here */ }
}
C. public synchronized void go ( ) { /* code here */ }
D. private synchronized (this) void go ( ) { /* code here */ }
E. void go ( ) {
synchronized (object.class) { /* code here */ }
}
F. void go ( ) {
synchronized (o) { /* code here */ }
}

Answer: C,E,F

[size=2][b][color=blue]解释:[/color][/b]答案CEF[/size]
[size=2][/size]
[size=2]这道题考查的是synchronized关键字的用法。使用synchronized关键字在定义方法的时候,既可以在声明部分,也可以在方法内部。[color=blue][b]synchronized关键字只能同步方法,而不能同步变量或类[/b][/color]。[/size]
[size=2]synchronized关键字在声明方法时的用法是:[/size]
[size=2]修饰符 + synchronized + 返回类型 + 方法名(参数列表) {},例如,public synchronized void methodA(int x) {...}[/size]
[size=2][/size]
[size=2]synchronized关键字写在方法内的用法是:[/size]
[size=2]public void methodB(int x) {[/size]
[size=2]      synchronized([color=blue][b]this[/b][/color]) {[/size]
[size=2]            ......[/size]
[size=2]      }[/size]
[size=2]}
[/size]
[size=2]或者:[/size]
[size=2]public void methodB(int x) {[/size]
[size=2]      synchronized([b][color=blue]SomeClass.class[/color][/b]) {[/size]
[size=2]            ......[/size]
[size=2]      }[/size]
[size=2]}[/size]
[color=blue][b][size=2]SomeClass.class称为类字面量(class literal),告诉JVM,去查找表示称为SomeClass的类的Class实例。[/size]
[/b][/color][size=2][/size]
[size=2]我们再回过头来看错误选项:[/size]
[size=2]A 错误之处在于不能给一个变量声明为synchronized[/size]
[size=2]B synchronized块的括号内需要加上类指向的对象[/size]
[size=2]D 在声明方法的synchronized不必加括号[/size]

[size=2][color=blue][b]代码:[/b][/color][/size][code]public class Test {

        Object o = new Object();
        
        // private synchronized object o; // A

        public static void main(String[] args) throws Exception {
                new Test().go();
        }

//        void go() { // B
//                synchronized() { /* ocde here */ }
//        }
        
//        public synchronized void go() { /* code here */ } // C
        
//        private synchronized (this) void go() { /* code here */ } // D
        
//        void go() { // E
//                synchronized (Object.class) { /* code here */ }
//        }
        
        void go ( ) { // F
                synchronized (o) { /* code here */ }
        }

}[/code]QUESTION 18
Exhibit:
[attach]177635[/attach]
What is the result?
A. The code will deadlock
B. The code may run with no output
C. An exception is thrown at runtime
D. The code may run with output " 0 6 "
E. The code may run with output "2 0 6 4"
F. The code may run with output "0 2 4 6"

Answer: F

[size=2][color=blue][b]解释:[/b][/color]答案F[/size]
[size=2][/size]
[size=2]这道题考查的是线程应用的综合知识。该程序完全没有问题,不仅合法,也完全符合java代码编写格式,很漂亮。这里既考到了wait()、notify()方法的用法(注意,wait()方法需要处理异常,这里是用try/catch块包围),也考到了数组与增强型for循环的用法。定义了4个Computation类,放入Computations数组中,并依次启动线程。再用for循环输出。不多说,看代码:[/size]

[size=2][color=blue][b]代码:[/b][/color][/size][code]public class Test extends Thread {

        private int num;

        private boolean isComplete;

        private int result;

        public Test(int num) {
                this.num = num;
        }

        public synchronized void run() {
                result = num * 2;
                isComplete = true;
                notify();
        }

        public synchronized int getResult() {
                while (!isComplete) {
                        try {
                                wait();
                        } catch (InterruptedException e) {
                                e.printStackTrace();
                        }
                }
                return result;
        }

        public static void main(String args[]) {
                Test[] tests = new Test[4];
                for (int i = 0; i < tests.length; i++) {
                        tests[i] = new Test(i);
                        tests[i].start();
                }
                for (Test t : tests) {
                        System.out.print(t.getResult() + " ");
                }
        }
}[/code][size=2][color=blue][b]输出:[/b][/color][/size][code]0 2 4 6 [/code]

[[i] 本帖最后由 非常菜 于 2007-7-2 12:02 编辑 [/i]]

非常菜 2007-7-2 12:02

Q19 & Q20

QUESTION 19
Given the exhibit:
[attach]177731[/attach]
What is the result?
A. Compilation fails
B. An exception is thrown at runtime
C. The code executes normally and prints "sleep"
D. The code executes normally, but nothing is printed.

Answer: C

[size=2][color=blue][b]解释:[/b][/color]答案C[/size]
[size=2][/size]
[size=2]这道题考查的仅仅是Thread类sleep()方法的用法。sleep()方法是Thread类的一个[color=blue][b]静态方法[/b][/color],它使得当前线程进入睡眠状态,参数是以毫秒计算的long型变量,表示睡眠时间,超过这个时间线程醒来回到可执行状态。[color=blue][b]该方法经常用于让其他线程有更大的机会执行,但不是保证,要记住,所有线程的执行都是没有保证的[/b][/color]。所以这里,当你运行的时候,你可以记数:1,2,3……然后打印出“sleep”。[/size]

[b][size=2][color=blue]代码:[/color][/size][/b][code]public class Test {
        public static void main(String args[]) throws Exception {
                Thread.sleep(3000);
                System.out.print("sleep");
        }
}[/code]

[b][size=2][color=blue]输出:[/color][/size][/b][code]sleep[/code]


QUESTION 20
Which two statements are true about has-a and is a relationships? (choose two)
A. Inheritance represents an is -a relationship
B. Inheritance represents a has-a relationship
C. Interfaces must be used when creating a has-a relationship
D. Instance variables can be used when creating a has-a relationship

Answer: A,D

[size=2][b][color=blue]解释:[/color][/b]答案AD[/size]
[size=2][/size]
[size=2]这道题考查的是OO编程的复合和继承的最基本概念。aggregation复合是has-a关系,inheritance继承是is-a关系,太简单,太基本了,不说了。[/size]

[[i] 本帖最后由 非常菜 于 2007-7-2 12:20 编辑 [/i]]

jiya0011 2007-7-2 22:54

关于第14题,我在matrix上也问过,别人是这么解释的:

InterruptedException是unchecked的Exception,要么catch,要么throws;若没有catch或throws编译不能通过

IllegalMonitorStateException(B选项说得不对吧,没有IllegalStateExcepion)是checked exception,在运行时抛出

抛出IllegalMonitorStateException的原因是
synchronized中的对象与调用wait的对象不一致

[code]public class WaitTest {

    public WaitTest() {
    }
    void waitForSignal() throws Exception{
            Object obj = new Object();
            synchronized(obj){
                obj.wait();
                obj.notify();
        }
        }
        
        public static void main(String[] args) throws Exception{
                new WaitTest().waitForSignal();
        }

}[/code]

这样没有编译错误,也可以运行,但运行的结果是main线程永远等在那里,除了等待,它什么也不能做,但它等待的是把自己唤醒(notify)

[code]public class WaitTest {

    public WaitTest() {
    }
    void waitForSignal() throws Exception{
            Object obj = new Object();
            synchronized(obj){
                    obj.notify();
                obj.wait();
        }
        }
        
        public static void main(String[] args) throws Exception{
                new WaitTest().waitForSignal();
        }
}[/code]

交换notify和wait的顺序,结果一样。但这回是main线程先唤醒自己,从这以后它不会再唤醒(notify)自己,然后又一直等待着唤醒自己

非常菜 2007-7-3 10:20

回复 #17 jiya0011 的帖子

欢迎参与讨论!

对于第一个代码片断,我是有疑惑的,
[code]void waitForSignal() throws Exception{
            Object obj = new Object();
            synchronized(obj){
                obj.wait();
                obj.notify();
        }
        }
[/code]

这里synchronized(obj)和obj.wait()方法的obj不是同一个对象的变量么?那这样对于IllegalMonitorStateException不就不适用了?

非常菜 2007-7-3 10:49

Q21 & Q22

QUESTION 21
Given the exhibit:
[attach]177889[/attach]
What can directly access and change the value of the variable name?
A. any class
B. only the Target class
C. any class in the Certkiller package
D. any class that extends Target

Answer: C

[size=2][b][color=blue]解释:[/color][/b]答案C[/size]
[size=2][/size]
[size=2]这道题考查的是访问修饰符的用法。注意到这里的Target类前没有访问修饰符而变量是public型的,那么就是default级别,[color=blue][b]default级别指,在同一个package中的其他类可以访问该类[/b][/color]。因此选C。[/size]


QUESTION 22
Which three statements are true? (choose three)
A. A final method in class x can be abstract if and only if X is abstract
B. A protected method in class x can be overridden by any subclass of x.
C. A private static method can be called only within other static methods in class X.
D. A non-static public final method in class X can be overridden in any subclass of X.
E. A public static method in class X can be called by a subclass of X without explicitly
referencing the class x.
F. A method with the same signature as a private final method in class X can be
implemented in a subclass of X.

Answer: B,E,F

[size=2][color=blue][b]解释:[/b][/color]答案BEF,对于F选项,我是有疑惑的。

这道题考查的还是加诸方法前的各种修饰符的用法,我们一个一个来看。

A [color=blue][b]请记住,永远不能同时使用final和abstract修饰一个方法。[/b][/color]为什么?abstract表示该方法是一个抽象方法,定义这样一个方法,目的是让该方法所在类的子类复写该方法,这是多态性的一个应用。而使用了final关键字后,该方法不允许该方法所在类的子类复写该方法,因此矛盾!所以,这两个修饰符永远永远不能一起使用。

B [color=blue][b]protected修饰的方法,对于该方法所在类的所有子类,包内的和包外的,均可见。[/b][/color]当然可以复写啦。

C 该选项错就错在“only”这个词。虽然private static型的方法可以被该类中的其他静态方法调用,但是[b][color=blue]对于该类中的动态方法也是可以调用的[/color][/b]!不是“只有”!

D 前面已经说过了,定义为final的方法不能被复写,不管是不是public,不管是包内还是包外的子类。但是final定义的方法是可以被调用的,这点不要搞混淆了!

E 这是对的,[color=blue][b]子类可以直接调用超类的静态方法,而无须显式地写出超类类名[/b][/color],见后面的代码。

F [color=darkgreen][b]我的疑问在这[/b][/color]。毫无疑问,通过排除法,F必选。我的理解在implemented这个单词处出现了问题。刚才也已经说了,任何声明为final的方法都是无法被复写的,[b][color=blue]那么implemented如果被理解成“实现”呢?那也应该是无法被实现的。但,如果这里把implemented理解成“执行”,那是对的,通过实例化该方法所在类,然后调用该方法。[/color][/b]所以,我觉得这里应该是理解为执行。但是题目中这个单词确实很容易产生歧义![/size]

[b][size=2][color=blue]代码:[/color][/size][/b][code]class TestA {
        public static void methodA() {
                System.out.println("methodA");
        }
}

public class Test extends TestA{
        public static void main(String args[]) {
                methodA();
        }
}[/code][size=2][color=blue][b]输出:[/b][/color][/size][code]methodA[/code]

非常菜 2007-7-6 14:23

Q23 & Q24

[size=2][color=darkgreen]这几天忙着准备考试,还重装了系统,抱歉。今天开始重新恢复更新。[/color][/size]

QUESTION 23
Place the Types in one of the Type columns, and the Relationships in the
Relationship column, to define appropriate has-a and is-a relationships.
[attach]178069[/attach]
Answer:
Explanation: Pending.

[size=2][b][color=blue]解释:[/color][/b]

这道题考查的就是面向对象程序设计中的“IS-A”关系和“HAS-A”关系。正确答案应该是:
Dog is-a Animal
Forest has-a Tree
Rectangle has-a Side
Java Book is-a Programming Book
很简单,不多说了。
[/size]

QUESTION 24
Replace two of the Modifiers that appear in the Single class to make the code compile.
Note: Three modifiers will not be used and four modifiers in the code will remain
unchanged.
[attach]178070[/attach]
Answer:
Explanation: Pending.

[size=2][color=blue][b]解释:[/b][/color]需要把第五块的“private”修改成“protected”,把第六块的“protected”修改成“static”

这道题考查的是修饰符的用法。子类调用的超类的构造函数被定义成private,所以不可见,修改成protected即可。而在静态方法getInstance()调用非静态方法create()也是不合法的,修改成static关键字即可。事实上,这道题的Single类的写法就是一种常用的设计模式“Singleton”模式。
[/size]
[b][size=2][color=blue]代码:[/color][/size][/b][code]public class Single {
        private static Single instance;
        
        public static Single getInstance() {
                if (instance == null)
                        instance = create();
                return instance;
        }
        
        protected Single() {}
        static Single create() {
                return new Single();
        }
}

class SingleSub extends Single {
        
}[/code]

非常菜 2007-7-9 12:28

Q25 & Q26

QUESTION 25
Exhibit:
[attach]178104[/attach]
What is the result?
A. Value is : 8
B. Compilation fails.
C. Value is : 12
D. Value is ; -12
E. The code runs with no output
F. An exception is thrown at runtime.

Answer: A

[size=2][b][color=blue]解释:[/color][/b]答案A

这道题考查的是实例变量value和局部变量value,以及变量间的传递关系。程序从MultiClac类的main()方法进入,先实例化MultiClac类,第10行的方法传入值“2”,进入第3行的方法;再通过第4行,调用第2行方法,注意,这里的value是继承自超类的实例变量,int型变量在定义时自动初始化为“0”。因此,运行第2行代码后,结果value=-3;再通过第5行调用超类第3行的方法,结果value=4;再运行子类第6行代码,value=8,最后打印输出。[/size]

[size=2][b][color=blue]代码:[/color][/b]对SimpleCalc类略作了改动,使两个类能放在一个文件中。[/size][code]class SimpleCalc {
        public int value;
        public void calculate() {
                value += 7;
        }
}

public class MultiCalc extends SimpleCalc {
        public void calculate() {
                value -= 3;
        }
        

        public void calculate(int multiplier) {
                calculate();
                super.calculate();
                value *= multiplier;
        }
        
        public static void main(String[] args) {
                MultiCalc calculator = new MultiCalc();
                calculator.calculate(2);
                System.out.println("Value is: " + calculator.value);
        }
}[/code][b][size=2][color=blue]输出:[/color][/size][/b][code]Value is: 8[/code]QUESTION 26
Given the exhibit:
[attach]178105[/attach]
Which statement is true?
A. The class is fully encapsulated
B. The code demonstrates polymorphism.
C. The ownerName variable breaks encapsulation
D. The CardID and limit variables break polymorphism
E. The setCardInformation method breaks encapsulation

Answer: C

[size=2][b][color=blue]解释:[/color][/b]答案C

该题考查了OO程序设计中“封装encapsulation”的概念。一个良好的OO程序设计,所有内部的变量需要用private保护,通过对外公开的setter/getter方法调用本类中实例变量的对象或值。这里很明显第24行定义的ownerName变量没有进行很好的封装。[/size]

非常菜 2007-7-10 11:04

Q27 & Q28

QUESTION 27
Given the exhibit:
[attach]178196[/attach]
What is the result?
A. peep
B. bark
C. meow
D. Compilation fails.
E. An exception is thrown at runtime

Answer: E

[size=2][color=blue][b]解释:[/b][/color]答案E

这道题考查的是Java多态性和强制类型转换方面的知识点。Cat和Dog继承自(IS-A)Animal,Dog向上转型自Animal没有问题。关键是31行把animal强制转换成Cat类型,强制转换可以通过,无条件。[color=blue][b]但是在运行的时候,虽然你声明该变量是Cat类型,但是编译器实际看到的是Dog类型,这就是多态,声明类型和JVM实际看到的对象类型并不一致。[/b][/color]这样就会引发执行期异常。[/size]

[size=2][color=blue][b]代码:[/b][/color][/size][code]class Animal {
        public String noise() {
                return "peep";
        }
}

class Dog extends Animal {
        public String noise() {
                return "back";
        }
}

class Cat extends Animal {
        public String noise() {
                return "move";
        }
}


public class Test {
        
        public static void main(String args[]) {
                Animal animal = new Dog();
                Cat cat = (Cat) animal;
                System.out.println(cat.noise());
        }
}[/code][b][size=2][color=blue]输出:[/color][/size][/b][code]Exception in thread "main" java.lang.ClassCastException: Dog
        at Test.main(Test.java:24)[/code]QUESTION 28
Exhibit:
[attach]178197[/attach]
What two must the programmer do to oerrect the compilation errors?
A. insert a call to this ( ) in the Car CONSTRUCTOR
B. insert a call to this ( ) in the MeGo constructor
C. insert a call to super ( ) in the MeGo constructor
D. insert a call to super (vin) in the MeGo constructor
E. change the wheel Count variable in CAR TO PROTECTED
F. CHANGE LINE 3 IN THE MeGo class to super wheel Count =3;

Answer: D,E

[size=2][color=blue][b]解释:[/b][/color]答案DE

解释:这道题考查的是继承对构造函数的影响和this()、super()方法的使用。要注意,[color=blue][b]每个类都有一个默认构造函数,但是当我们人为给定类的构造函数的时候,默认构造函数就会失效。[/b][/color]this()根据其参数的不同,调用的是本类中的其他重载构造函数,super()根据参数的不同调用的是超类的各种重载构造函数。现在一个个来看选项:

A 因为Car类已经人为给定了一个带String参数的构造函数,因此默认的构造函数public Car() {}将不再可用。因此通过this()调用Car()无效。

B 类似A

C 由A得知,无法通过super()调用Car()构造函数

D 通过super(String)可以调用Car(String)构造函数

E 把超类的wheelCount变量的修饰符改为protected,那么该变量对于子类可见,因此子类中可以调用该变量。

F 现在的wheelCount变量是private型的,对于子类也不可见,因此还是无法在子类中调用。
[/size]
[b][size=2][color=blue]代码:[/color][/size][/b][code]class Car {
//        private int wheelCount;
        protected int wheelCount; // E
        private String vin;
        
        public Car(String vin) {
//                this(); // A
                this.vin = vin;
                this.wheelCount = 4;
        }
        
        public String extend() {
                return "zoom";
        }
}

public class MeGo extends Car {
        public MeGo(String vin) {
//                this() // B
//                super(); // C
                super(vin); // D
//                super.wheelCount = 3; // F
                this.wheelCount = 3;
        }
}[/code]

[[i] 本帖最后由 非常菜 于 2007-7-10 11:55 编辑 [/i]]

非常菜 2007-7-11 10:10

Q29 & Q30

QUESTION 29
Given the exhibit:
[attach]178306[/attach]
What three code fragments inserted individually at line 15, make use of polymorphism? (choose three)
A. public void add (C c) { c.getValue ( ); }
B. public void add (B b) { b.getValue ( ); }
C. public void add (A a) { a.getValue ( ); }
D. public void add (A a, B b) { a.getValue ( ); }
E. public void add (C c1 C c2) { c1.getValue ( ); }

Answer: B,C,D

[size=2][color=blue][b]解释:[/b][/color]答案BCD

这道题考查的是多态的概念。我的理解是[color=blue][b](不一定准确)[/b][/color],因为应用多态,那么子类即满足IS-A关系,继承树上的所有超类对于子类均可见,子类可以直接调用超类对象以及超类中的方法。由此可见,BCD均是直接使用超类对象,是多态的一种应用。[/size]

QUESTION 30
Given the exhibit:
[attach]178307[/attach]
Which statement should be placed at line 14 to suggest that the virtual machine
expend effort toward recycling the memory used by the object Certkiller ?
A. System.gc ( )
B. Runtime. Gc ( )
C. System.freeMemory ( )
D. Runtime.getRuntime ( ) growHeap ( )
E. Runtime.getRuntime ( ) free Memory ( )

Answer: A

[size=2][color=blue][b]解释:[/b][/color]答案A

这道题考查的是JVM垃圾收集。要注意,[color=blue][b]垃圾收集只是你希望JVM去做,但并不能保证JVM能帮你删除内存中所有不使用的对象[/b][/color]。垃圾收集最简单的方法就是[color=blue][b]System.gc()[/b][/color]。

B Runtime中的gc()不是静态方法,不能Runtime.gc()这样调用

C freeMemory()方法返回内存剩余量,而非用于垃圾收集

DE 使用Runtime中的gc()的正确方法是:[color=blue][b]Runtime.getRuntime().gc();[/b][/color]由此可见DE错误。[/size]

非常菜 2007-7-13 11:27

Q31 & Q32

QUESTION 31
Exhibit:
[attach]178450[/attach]
What is the output of the program shown in the exhibit?
A. 300.100.100.100.100
B. 300.300.100.100.100
C. 300.300.300.100.100
D. 300.300.300.300.100

Answer: B

[size=2][b][color=blue]解释:[/color][/b]答案B[/size]
[size=2][/size]
[size=2]这道题考查的是各种变量的区分。程序在第25行,给x变量赋值为“300”,所以第26行第一次打印“300”;第28行,将foo作为fooBar()方法的参数,见19行该方法的定义,返回的Foo对象中的x变量为“100”;要注意的是,29行打印的是foo变量所引用的对象中的x变量,此x变量值仍为“300”,在30行打印的是fooFoo变量所引用的对象中的x变量,那么打印的就是“100”;由于在第32行fooFoo作为参数放入fooBar()方法,并将foo指向该对象,则第33行和第34行打印的都是“100”。[/size]

[size=2][color=blue][b]代码:[/b][/color][/size]
[code]class Foo {
        private int x;
        public Foo (int x) {
                this.x = x;
        }
        
        public int getX() {
                return x;
        }
        
        public void setX(int x) {
                this.x = x;
        }
}

public class Submit {
        static Foo fooBar(Foo foo) {
                foo = new Foo(100);
                return foo;
        }
        
        public static void main(String[] args) {
                Foo foo = new Foo(300);
                System.out.print(foo.getX() + ".");
               
                Foo fooFoo = fooBar(foo);
                System.out.print(foo.getX() + ".");
                System.out.print(fooFoo.getX() + ".");
               
                foo = fooBar(fooFoo);
                System.out.print(foo.getX() + ".");
                System.out.print(fooFoo.getX());
        }
}[/code]

[size=2][color=blue][b]输出:[/b][/color][/size]
[code]300.300.100.100.100[/code]


QUESTION 32
A developer is creating a class Book, that needs to acces class Paper. The Paper
class is deployed in a JAR named myLib.jar.
Which three, taken independently, will allow the developer to use the Paper class
while compiling the Book class? (choose three)

A. The JAR file is located at $JAVA_HOME/jre/classes/myLib.jar
B. The JAR file is located at $/JAVA_HOME/jre/lib/ext/myLib.jar..
C. The JAR file is located at /foo/myLib.jar and a classpath environment variable is set
that includes /foo/myLib.jar/Paper,Class.
D. The JAR file is located at /foo/myLib.jar and a classpath environment variable is set
that includes /foo/myLib.jar.
E. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac
-cp /foo/myLib.jar/Paper Book java.
F. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -d
/foo/myLib.jar Book java.
G. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac
-classpath /foo/myLib.jar Book java

Answer: B,D,G

[size=2][b][color=blue]解释:[/color][/b]答案BDG[/size]
[size=2][/size]
[size=2]这道题考查的是使用jar文件的运行和编译方法。可以分成AB、CD、EFG三部分来看:[/size]
[size=2][/size]
[size=2]运行某一个class文件,第一种方法就是将jar文件放在jre/lib/ext/目录下,这样java和javac命令就能找到该jar文件,并使用其内部的编译好的类文件,故B正确。[/size]
[size=2][/size]
[size=2]第二种方法是在环境变量里CLASSPATH里加入jar文件所在路径,不必写出jar文件的某一个类,这是最常用的方法,故D正确。[/size]
[size=2][/size]
[size=2]最后一种方法是在运行或者编译的时候指定CLASSPATH,让编译器去该CLASSPATH指定的路径下找,命令类似于 javac -classpath(或者-cp) xxx/xxx/xxx.jar  yyy.java的形式,F的错误之处在于-d参数是指定编译好的类存放的路径,而非用于API查找,故G正确。[/size]

[[i] 本帖最后由 非常菜 于 2007-7-13 11:28 编辑 [/i]]

非常菜 2007-7-14 12:21

Q33 & Q34

QUESTION 33
Given the exhibit:
[attach]178494[/attach]
Which statement is true about the object referenced by snoog, smooch and booch
immediately after line 23 executes?
A. None of these objects are eligible for garbage collection
B. Only the object referenced by booch is eligible for garbage collection
C. Only the pbject referenced by snoog is eligible for garbage colletion
D. Only the object referenced by smooch is eligible for garbage collection
E. The objects referenced by smooch and booch are eligible for garbage collection

Answer: E

[size=2][b][color=blue]解释:[/color][/b]答案E?[/size]
[size=2][/size]
[size=2]这道题考查的是垃圾收集的条件问题。有三种情况符合垃圾收集的条件:[/size]
[size=2][/size]
[size=2]1、空引用,对象的引用变量为空;[/size]

[size=2]2、重新为引用变量赋值,则引用变量前一个被引用的对象符合垃圾收集的条件;[/size]

[size=2]3、隔离引用,两个相互引用的实例,所有其他对这两个实例的引用都被删除,即这两个实例被隔离起来,均无法被外界访问了,则这两个实例可以被垃圾收集。[/size]
[size=2][/size]
[size=2]这道题答案E,但是我不确定。我是这么理解的:第23行执行后,Certkiller类和Boochy类没有外界的任何引用,虽然他们之间还是有引用关系的,但是无法被外界访问,类似于隔离岛,符合第三种条件。因此smooch和booch变量可被垃圾收集。[color=blue][b]我的问题是这里的snoog变量毫无疑问,也符合垃圾收集的条件(第一种),那么这里就有三个变量符合[/b][/color]。可能是题目中BCD都是说“Only”吧,这里出了问题,所以,虽然E没有包含全部符合垃圾收集的变量,但是正确答案。[/size]


QUESTION 34
Given the exhibit:
[attach]178495[/attach]
and the command line invocation
java Certkiller 5 a b c
what is the result?
A. a b
B. b c
C. a b c
D. Compilation fails
E. An exception is thrown at runtime

Answer: B

[size=2][b][color=blue]解释:[/color][/b]答案B[/size]
[size=2][/size]
[size=2]这道题考查的数组。要记住,数组里面的元素索引是从“0”开始的,比如这里yahoo[0]才是数组中的第一个元素,那么循环从索引1开始,即从数组第二个元素开始,只能显示“ b c”。[/size]

[b][size=2][color=blue]代码:[/color][/size][/b][code]public class Test {
        public static void main(String[] yahoo) {
                for (int x = 1; x < yahoo.length; x++) {
                        System.out.print(yahoo[x]);
                }
        }
}[/code][b][size=2][color=blue]输出:[/color][/size][/b][code] b c[/code]

非常菜 2007-7-15 12:39

Q35 & Q36

QUESTION 35
Given the exhibit:
[attach]178561[/attach]
What is the result?
A. r, t, t
B. r, e, o,
C. Compilation fails
D. An exception is thrown at runtime

Answer: C

[size=2][b][color=blue]解释:[/color][/b]答案C

这道题考查的是if条件判断问题。[color=blue][b]if()括号中的条件必须是boolean型[/b][/color]的,这里第13行很明显是一个赋值
语句。要注意的是,如果被赋值的变量如果是boolean变量,那么语句仍然合法,不过此处的check变量
是int型,则不合法,编译失败。

[b][color=blue]代码:[/color][/b][/size][code]public class Test {
        public static void main(String[] yahoo) {
                certkiller("four");
                certkiller("tee");
                certkiller("to");
        }
        
        public static void certkiller(String str) {
                int check = 4;
                if (check = str.length()) {
                        System.out.print(str.charAt(check -= 1) + "");
                } else {
                        System.out.print(str.charAt(0) + "");
                }
        }
}[/code][b][size=2][color=blue]输出:[/color][/size][/b][code]Exception in thread "main" java.lang.Error: 无法解析的编译问题:
        类型不匹配:不能从 int 转换为 boolean

        at Test.certkiller(Test.java:10)
        at Test.main(Test.java:3)[/code]QUESTION 36
Given the exhibit:
[attach]178562[/attach]
and the command line:
java - Drop.custom = gobstopper Certkiller
Which two, placed on line 13, will produce the output gobstopper? (choose two)
A. System.load ("prop.custom");
B. System.getenv ("prop.custom");
C. System.property ("prop.custom");
D. System.getProperty ("prop.custom");
E. System.getProperties ( ).getProperty ("prop.custom");

Answer: D,E

[size=2][b][color=blue]解释:[/color][/b]答案DE[/size]
[size=2][/size]
[size=2]这道题考查的是如何使用系统属性及其方法。有两种方法获得系统属性,一种是System.getProperty(String),另一种是Properties类中的getProperty(String)方法,DE分别采用这两种方法。另外一点要注意的是如题目这样的写法“java - Drop.custom = gobstopper Certkiller”是错误的,[color=blue][b]键=值必须紧随,中间不允许有空格[/b][/color],正确写法应该是“java -Drop.custom=gobstopper Certkiller”。错误选项:[/size]
[size=2][/size]
[size=2]A 用于载入代码文件作为动态库文件,且返回值为空[/size]
[size=2]B 用于获得指定的环境变量的值,返回的是Map集合[/size]
[size=2]C 无该方法[/size]
[size=2][/size]
[size=2][color=blue][b]代码:[/b][/color][/size][code]public class Test {
        public static void main(String[] yahoo) {
//                String myProp = System.load ("prop.custom"); // A
//                String myProp = System.getenv ("prop.custom"); // B
//                String myProp = System.property ("prop.custom"); // C
                String myProp = System.getProperty ("prop.custom"); // D
//                String myProp = System.getProperties().getProperty("prop.custom"); // E
                System.out.println(myProp);
        }
}[/code][b][size=2][color=blue]输出:[/color][/size][/b][code]gobstopper[/code]

非常菜 2007-7-16 21:41

Q37 & Q38

QUESTION 37
Given classes defined in two different files:
[attach]178683[/attach]
What is required at line 5 in class Certkiller App to use the process method of Bit Utils?

A. Process (bytes);
B. BitUtils.process (bytes);
C. Util.BitUtils.process (bytes);
D. Certkiller App cannot use methods in BitUtils
E. Import util.BitUtils.*; process (bytes);

Answer: C

[size=2][b][color=blue]解释:[/color][/b]答案C[/size]
[size=2][/size]
[size=2]本题考查的是不同包中静态方法的调用。只要记住,静态方法调用要写全调用路径,不同包的要从包名开始,同一个包内的,从类名开始写。所以,很明显C正确。[/size]


QUESTION 38
Exhibit:
[attach]178684[/attach]
What is the outcome of the code?

A. Compilation fails.
B. Gobstopper
Fizzylifting
C. Gobstopper
Scremdiddlyumptious
D. Scrumdiddlyumptious
Fizzylifting
E. Scrumiddlyumptious
Scrumdiddlyumptious

Answer: B

[size=2][b][color=blue]解释:[/color][/b]答案B[/size]
[size=2][/size]
[size=2]本题考查的是类型变量调用问题。要注意的是modifyDesc()方法是静态方法,该方法独立于Item类,永远只有一个副本,这里当it传入静态方法后,在静态方法中做的修改对第11行定义的it变量不产生影响。[/size]

[size=2][color=blue][b]代码:[/b][/color][/size][code]public class Item {
        private String desc;
        
        public String getDescription() {
                return desc;
        }

        public void setDescription(String d) {
                this.desc = d;
        }
        
        public static void modifyDesc(Item item, String desc) {
                item = new Item();
                item.setDescription(desc);
        }

        public static void main(String[] args) {
                Item it = new Item();
                it.setDescription("GobStopper");
                Item it2 = new Item();
                it2.setDescription("Fizzylifting");
                modifyDesc(it, "Scrumdiddlyumptious");
                System.out.println(it.getDescription());
                System.out.println(it2.getDescription());
        }
}[/code][size=2][color=blue][b]输出:[/b][/color][/size][code]GobStopper
Fizzylifting[/code]

非常菜 2007-7-17 12:01

Q39 & Q40

QUESTION 39
Given classes defined in two different files
[attach]178759[/attach]
What is required at line 5 in class Certkiller Application to use the process method of
BitUtils?

A. PROCESS (BYTES);
B. BitUtils.process(bytes);
C. App.BitUtils.process (bytes)
D. Util.BitUtils. process (bytes)
E. Import util.Bitutils.*; process (bytes);
F. Certkiller Application cannot use the process method in BitUtils.

Answer: F

[size=2][b][color=blue]解释:[/color][/b]答案F[/size]
[size=2][/size]
[size=2]这道题与37题很类似,唯一的区别是这里的process()方法是private型的,无法在类外访问。因此编译无法通过。[/size]


QUESTION 40
[attach]178760[/attach]
The image represents a complete package structure for a set of classes: "com" is the
beginning of the fully-qualified package name for all classes.
Give this package structure, insert the code needed to make the Car class compile
and runt successfully.
All three placeholds must be filled. If fewer than three statement are needed, use the
"// blank" options.
[attach]178761[/attach]
Answer:
Explanation: Pending.

[size=2][color=blue][b]解释:[/b][/color][/size]
[size=2][/size]
[size=2]这道题考查的是包和类的导入。[color=blue][b]要注意的是,“*”只能代替同一个包中的多个类。定义package的路径,要一直写到要编译类所在包,import也类似[/b][/color]。此处,要编译Car类,那么包就应该是“package com.bar;”。需要用到其它包中的Book和Dog类,那么导入类就应该是“import com.foo.bar.blatz.Book;”和“import com.foo.bar.Dog;”或者“import com.foo.bar.blatz.*;”和“import com.foo.bar.*;”。因此,黄框中依次填入“package com.bar;”、“import com.foo.bar.blatz.*;”和“import com.foo.bar.*;”。[/size]

非常菜 2007-7-18 16:22

Q41 & Q42

QUESTION 41
Given the exhibit:
[attach]178909[/attach]
What is the result when this ode executed?

A. 1
B. 3
C. 123
D. 321
E. The code runs with no output

Answer: C

[size=2][b][color=blue]解释:[/color][/b]答案C[/size]
[size=2][/size]
[size=2]这道题考查的是继承关系中,初始化问题。只要记住,子类初始化前一定先初始化超类,比如这里,初始化Certkiller3类,必先初始化Certkiller2类,而要初始化Certkiller2类,则要先初始化Certkiller1类,所以输出应该是“123”。[/size]

[b][size=2][color=blue]代码:[/color][/size][/b][code]class Certkiller1 {
        public Certkiller1() {
                System.out.print("1");
        }
}

class Certkiller2 extends Certkiller1 {
        public Certkiller2() {
                System.out.print("2");
        }
}

class Certkiller3 extends Certkiller2 {
        public Certkiller3() {
                System.out.print("3");
        }
}

public class Numbers {
        public static void main(String[] args) {
                new Certkiller3();
        }
}[/code][b][size=2][color=blue]输出:[/color][/size][/b][code]123[/code]QUESTION 42
Place the code fragments in position to complete the Displayable interface.
[attach]178910[/attach]
Answer:
Explanation: Pending.

[size=2][color=blue][b]解释:[/b][/color][/size]
[size=2][/size]
[size=2]这道题考查的是interface继承的问题。interface只能继承interface,interface不能implements(实现) interface,如果一个类实现了interface,那么必须对interface中的所有抽象方法进行实现,即有方法体。此处Displayable是一个interface,那么只能用关键字“extends”,然后选择继承的接口“Reloadable”,由于这还是一个接口,所以里面的方法一定不能有具体的实现,所以,方法要选择“public void display();”。[/size]

非常菜 2007-7-19 17:24

Q43 & Q44

QUESTION 43
Given the exhibit:
[attach]179021[/attach]
Which code, inserted at line 14, allows the Sprite class to compile?

A. Direction d = NORTH
B. Certkiller .Direction d = NORTH
C. Direction d = Direction.NORTH
D. Certkiller .Direction d = Certkiller Direction. NORTH

Answer: D

[size=2][b][color=blue]解释:[/color][/b]答案D[/size]
[size=2][/size]
[size=2]这道题考查的是枚举类型的声明和定义。只要记住,枚举类型的定义需要写全类路径即可。你可以把枚举看作是独立的类,但不能在方法内声明。枚举中的常量可以看作是static final型的常量,则定义就形如:Certkiller.Direction d = Certkiller.Direction.NORTH。[/size]

[b][size=2][color=blue]代码:[/color][/size][/b][code]public class Test {
        
        enum Direction {
                NORTH, SOUTH, EAST, WEST;
        }
        
        public static void main(String[] args) {
                Test.Direction d = Test.Direction.NORTH;
        }
}[/code]QUESTION 44
Exhibit:

Which three statements are true? (Choose three)
[attach]179022[/attach]
A. Compilation fails
B. The code compiles and the output is 2
C. If lines 16, 17 and 18 were removed, compilation would fail.
D. If lines 24,25, and 26 were removed, compilation would fail.
E. If lines 16,17 and 18 were removed, the code would compile and the output would be 2.
F. If line 24,25 and 26 were removed, the code would compile and the output would be 1.

Answer: B,E,F

[size=2][b][color=blue]解释:[/color][/b]答案BEF

本题考查的是内部类的定义和用法,特别是方法内部类。首先,Beta类能通过编译,不存在任何问题,[b][color=blue]此时打印的fubar(new A())中A类是定义在该方法中的内部类[/color][/b]。移去16~18行,打印结果不受影响,但是移去24~26行后,[b][color=blue]fubar(new A())中的A类是定义在Beta类中的内部类[/color][/b]。[/size]

[b][size=2][color=blue]代码:[/color][/size][/b][code]interface Foo {
        int bar();
}

public class Beta {
        
        class A implements Foo {
                public int bar() {
                        return 1;
                }
        }
        
        public int fubar(Foo foo) {
                return foo.bar();
        }
        
        public void testFoo() {
                class A implements Foo {
                        public int bar() {
                                return 2;
                        }
                }
                System.out.println(fubar(new A()));
        }
        
        public static void main(String[] args) {
                new Beta().testFoo();
        }
}[/code][b][size=2][color=blue]输出:[/color][/size][/b][code]2[/code]

非常菜 2007-7-20 09:50

Q45 & Q46

QUESTION 45
Add methods to the Beta class to make it compile correctly.
[attach]179051[/attach]
Answer:
Explanation: Pending.

[size=2][color=blue][b]解释:[/b][/color][/size]
[size=2][/size]
[size=2]这道题考查的是复写(override)和重载(overload)。[b][color=blue]重写的要求是很苛刻的:
1、复写方法的访问修饰符不能比被复写方法严格;
2、返回类型必须一致,但可以是被复写方法类型的子类;
3、参数相同。
[/color][/b]本题中,A的错误在于被复写方法是public型的,复写使用private修饰符,不满足第一个条件;DF的错误在于返回类型不一致,不满足第二个条件。[/size]

[b][size=2][color=blue]代码:[/color][/size][/b][code]class Alpha {
        public void bar(int... x) {}
        public void bar(int x) {}
}

public class Beta extends Alpha {
//        private void bar(int x) {} // A
        public void bar(int x) {} // B
        public int bar(String x) {return 1;} // C
//        public Alpha bar(int x) {} // D
        public void bar(int x, int y) {} // E
//        public int bar(int x) {return x;} // F
}[/code]QUESTION 46
[attach]179052[/attach]
Given the exhibit:
[attach]179053[/attach]
What is the output from line 5 of the Certkiller class?

A. 5
B. 10
C. 12
D. 17
E. 24

Answer: B

[size=2][b][color=blue]解释:[/color][/b]答案B[/size]
[size=2][/size]
[size=2]这道题考查的还是变量的问题。method()方法中的x变量一定是指传入的x变量,而非类中定义的实例变量,只要记住了这一点,这道题很容易就解决了,x += x; =〉x = x + x;所以结果是10。[/size]

[b][size=2][color=blue]代码:[/color][/size][/b][code]public class Test {
        
        int x = 12;
        
        public void method(int x) {
                x += x;
                System.out.println(x);
        }
        
        public static void main(String[] args) {
                Test t = new Test();
                t.method(5);
        }
}[/code][b][size=2][color=blue]输出:[/color][/size][/b][code]10[/code]

level133 2007-9-24 23:50

*** 作者被禁止或删除 内容自动屏蔽 ***

whoare 2008-1-21 17:26

支持楼主 万分感动!

whoare 2008-1-24 22:25

[quote]原帖由 [i]非常菜[/i] 于 2007-6-29 11:16 发表
QUESTION 14
Given the exhibit:[code]Exception in thread "main" java.lang.IllegalMonitorStateException: current thread not owner
        at java.lang.Object.wait(Native Method)
        at java.lang.Object.wait(Unknown Source)
        at waittests.waitForSignal(waittests.java:8)
        at waittests.main(waittests.java:14)[/code]Q14.jpg (12.49 KB)
2007-6-29 11:16

Which statement is true?
A. This code may throw an InterruptedException
B. This code may throw an IllegalStateExcepion
C. This code may throw a TimeOutException after ten minutes
D. This code will not compile unless "obj.wait ( ) \" is replaced with " (( Thread) obj)
.wait ( )"
E. Reversing the order of obj.wait ( ) and obj. notify ( ) may vcause this method to
complete normally

Answer: B

解释:答案A?

这道题,我是有疑惑的,我觉得是选A。这里考查的是Object类中有关线程的两个方法,要注意的是,wait()、sleep()和join()方法要声明异常InterruptedException(其中,后两个方法是Thread类中的方法)。很明显,wait()方法没有声明抛出异常或者用try/catch包围。
[/quote] 我觉得B是对的
[url=http://java.sun.com/j2se/1.3/docs/api/java/lang/IllegalMonitorStateException.html][color=Blue]IllegalMonitorStateException[/color][/url]会抛出,因为synchronized(Thread.currentThread())的Thread.currentThread 没有权利调用obj.wait(); 如果synchronized(obj)就可以通过了
[color=Blue]代码[/color][code]public class waittests {

public waittests() {
}
void waitForSignal() throws Exception{
Object obj = new Object();
synchronized(Thread.currentThread()){
obj.wait();
obj.notify();
}
}

public static void main(String[] args) throws Exception{
new waittests().waitForSignal();
}

}[/code][color=Blue]输出[/color][code]Exception in thread "main" java.lang.IllegalMonitorStateException: current thread not owner
        at java.lang.Object.wait(Native Method)
        at java.lang.Object.wait(Unknown Source)
        at waittests.waitForSignal(waittests.java:8)
        at waittests.main(waittests.java:14)[/code]

[[i] 本帖最后由 whoare 于 2008-1-24 22:28 编辑 [/i]]

fengxiaoxiao 2008-1-25 16:47

菜菜太厉害了
做了这么多真是辛苦了
支持一下
一定要好好学一下
不能辜负了菜菜的苦心啊

mgp1988 2008-2-2 21:59

菜鸟兄辛苦了,我加到收藏夹里,推荐给大家

ycy290 2008-3-19 14:09

非常钦佩LZ的奉献精神,希望有一天我也能加入进来。

q421443815 2008-3-28 21:08

Actualtests 310-055 出2008/1月的了 多了几题
楼主的学习态度值得学习:loveliness:

箱子 2008-4-7 23:31

好帖子,做个记号,以后每天都来做.

fesxe 2008-4-10 15:12

不错的想法...UP
页: [1] 2
查看完整版本: SCJP 天天做