由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - 问一个SCJP 题目
相关主题
线程问题。问个基本问题
一道java题有熟悉Java Reflection的吗
请问一个serialize class object下载运行的问题Apply lock on a class.
如何传递secret key问一个关于access object instance的问题
writeObject()的时候出现NotSerializableException是怎么回事?Re: Can Web Services return Hash or Obje
type conversionsQuestions on EJB3 Persistence/Hibernate
how to copy an Object?有多少人对annotation这个东西不满,请举手!!
问题征解其实有没有而已解释一下java ee是什么
相关话题的讨论汇总
话题: dog话题: instance话题: animal话题: serialize话题: output
进入Java版参与讨论
1 (共1页)
a******s
发帖数: 7
1
Test Question [1]
Given:
5. class NoGo implements Runnable {
6. private static int i;
7. public synchronized void run() {
8. if (i%10 != 0) { i++; }
9. for(int x=0; x<10; x++, i++)
10. { if (x == 4) Thread.yield(); }
11. }
12. public static void main(String [] args) {
13. NoGo n = new NoGo();
14. for(int x=0; x<101; x++) {
15. new Thread(n).start();
16. System.out.print(i + " ");
17. } } }
Which is true?
A. The output can never contain the value 10.
B. The output can never contain the value 30.
C. The output can never contain the value 297.
D. The output can never contain the value 820.
E. Making the run method un-synchronized will NOT change the possible
output.
Test Question [2]
Which two about using the java.io.Serializable class are true? (Choose two.)
A. If Dog extends Animal, then Animal must implement java.io.Serializable
in order to serialize an instance of Dog.
B. If Dog has-a Collar, then Collar must implement java.io.Serializable in
order to serialize an instance of Dog.
C. If Dog extends Animal and Animal implements java.io.Serializable but
Dog does NOT implement java.io.Serializable, you can serialize an instance
of Dog.
D. When an instance of a subclass is deserialized, none of the
constructors in it's constructor chain will ever be invoked.
E. If you mark a class's instance variable volatile, and then serialize an
instance of that class, the state of the volatile variable will be lost
during serialization.
I don't think B is right, because Collar can be transient.
z****e
发帖数: 54598
2
E
CD
A-是否Serializable,只需要本类继承接口就行了,跟父类无关
B-理由同上,这个是markup interface,看到接口,就可以序列化
E-volatile和transient故意混淆
b****u
发帖数: 1130
3
不理解第一题的答案 E
1 (共1页)
进入Java版参与讨论
相关主题
其实有没有而已解释一下java ee是什么writeObject()的时候出现NotSerializableException是怎么回事?
legacy code里竟然还有scriplet,sightype conversions
Re: Challenge: Who can solve this problem? Thanxhow to copy an Object?
SCJP Books问题征解
线程问题。问个基本问题
一道java题有熟悉Java Reflection的吗
请问一个serialize class object下载运行的问题Apply lock on a class.
如何传递secret key问一个关于access object instance的问题
相关话题的讨论汇总
话题: dog话题: instance话题: animal话题: serialize话题: output