147之真题大讨论!

flyday 2003-06-24 08:29:58
希望绝顶高手指教!

2. Given: ?
Integer i = new Integer (42);
Long 1 = new Long (42);
Double d = new Double (42.0);
Which two expressions evaluate to True? (Choose Two)
A. (i ==1)
B. (i == d)
C. (d == 1)
D. (i.equals (d))
E. (d.equals (i))
F. (i.equals (42))
Standard Answer: D,E
My Answer: No Answer!
Comment: Different object can't compare each other!

11. Which two demonstrate an “is a” relationship? (Choose Two)
A. public interface Person { }
public class Employee extends Person { } n
B. public interface Shape { }
public class Employee extends Shape { }n
C. public interface Color { }
public class Employee extends Color { }n
D. public class Species { }
public class Animal (private Species species;)
E. interface Component { }
Class Container implements Component (
Private Component[ ] children;
)e
Standard Answer: D,E
My Answer: E
Commend:D is a "Has a " relation!

29. Given:
1. byte [] arry1, array2[];
2. byte array3 [][];
3. byte[][] array4;
If each array has been initialized, which statement will cause a compiler error?
A. array2 = array1;
B. array2 = array3;
C. array2 = array4;
D. both A and B
E. both A and C
F. both B and C
Standard Answer: F
My Answer: A
Commend:byte [] arry1,array2[];is equal to
byte[] arry1;
byte[][] array2;

?55. Which two CANNOT directly cause a thread to stop executing? (Choose Two)
A. Calling the yield method//cannot
B. Calling the wait method on an object//can
C. Calling the notify method on an object//can
D. Calling the NotifyAll method on an object//can
E. Calling the start method on another Thread object//cannot
Standard Answer:A,E
My Answer: E, I am not sure!
Commend: Because yield can cause the thread that has same priority stop!

57. Given:
1. public class SyncTest (
2. private int x;
3. private int y;
4. private synchronized void setX (int i) (x=1;)
5. private synchronized void setY (int i) (y=1;)
6. public void setXY(int 1)(set X(i); setY(i);)
7. public synchronized Boolean check() (return x !=y;)
8. )
Under which conditions will check () return true when called from a different class?
A. Check() can never return true
B. Check() can return true when setXY is called by multiple threads y
C. Check() can return true when multiple threads call setX and setY separately. y
D. Check() can only return true if SyncTest is changed to allow x and y to be set separately. n
bc
Standard Answer: B
My Answer: B,C
Commend:If a thread call setX(0) and another thread call check(),now what is check() return? It is true;

?60. Which two CANNOT directly cause a thread to stop executing? (Choose Two)
A.Existing from a synchronized block
B.Calling the wait method on an object//can
C.Calling notify method on an object//can not
D.Calling read method on an InputStream object//can
E.Calling the SetPriority method on a Thread object//can
Standard Answer: A,C
My Answer:
Commend: 55

???74. Click the exhibit button:
1. public class Mycircle {
2. public double radius;
3. public double diameter;
4.
5. public void setRadius(double radius)
6. this.radius = radius;
7. this.diameter= radius * 2; 8. } 9.
10. public double getRadius() {
11. return radius; 12. } 13. }
Which statement is true?
A. The Mycircle class is fully encapsulated.
B. The diameter of a given MyCircle is guaranteed to be twice its radius. y
C. Lines 6 and 7 should be in a synchronized block to ensure encapsulation.
D. The radius of a MyCircle object can be set without affecting its diameter. y
Standard Answer: B
My Answer: B, D
Commend:Because radius is public,so I can set it without affectiong its diameter.

...全文
78 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
skywinner 2003-07-30
  • 打赏
  • 举报
回复
2.无答案,
Compares this object to the specified object. The result is true if and only if the argument is not null and is an Integer object that contains the same int value as this object,这是jdk帮助上的原话,出这到题的人身边肯定没有jdk帮助^_^

11.我怀疑题目应该是has a,答案是de

29.答案a,明显的错误,我怀疑给原答案的人当时肚子在痛^_^

55.有人争论过,最后定的答案是ae,我觉得a不大对,因为yield就是让当前线程暂停,给其他线程一个运行机会,但是并不是确定要让出运行权。但它有可能会造成当前线程暂停。notify是把一个线程唤醒,并把新唤醒的线程放到锁等待队列中,而不是runnable队列,还要注意的是调用notify时当前线程正占有这个对象的锁,所以唤醒的线程不可能马上申请到锁并排到runnable队列中,所以唤醒的线程不可能立刻剥夺当前线程的运行权,也就是说notify不会直接导致当前线程交出运行权。notifyAll同理。start是把新线程放到runnable队列中,这样新的线程就有可能立刻运行,这里就要看怎么理解了,我的理解是正是因为start加了一个新线程到runnable队列中才使得当前线程有可能交出运行权(但不是确定),它们之间有直接关系。我的答案还是cd

57.B,setX,setY是private的,出了SyncTest的左右大括号谁也别想动它,线程只能是望洋兴叹了^_^

60.和55有些相似。AC。如果按照start的解释,我觉得A也有些问题,不好讨论了^_^,不过考试时我还是会觉得选AC最恰当(开始耍赖了^_^),至于SetPriority没问题吧,给人家设置一个比自己还高的优先级那自己立刻让出运行权,没说的。

74.d,因为radius和diameter都是public的,我当然可以给radius赋值而不理会diameter,如果d对了b就自然不对了,如果给radius赋值5,给diameter赋值6,那个diameter想是radius的两倍只有做梦的份了^_^


我对scjp没兴趣,主要是喜欢的mm要考所以自己只能舍命陪君子了(^_^,有点夸大了哈),上面的是我的一些看法,欢迎讨论
stronghdq 2003-07-22
  • 打赏
  • 举报
回复
74题看来是e文理解的问题,请看D选项
D. The radius of a MyCircle object can be set without affecting its diameter.
意思是设置 radius 时不会影响diameter,这显然是错误的
stronghdq 2003-07-22
  • 打赏
  • 举报
回复
29题,明显的数组声明问题
byte [] arry1, array2[];//都是一维数组
byte array3 [][];//二维数组
byte[][] array4;//二维数组
stronghdq 2003-07-22
  • 打赏
  • 举报
回复
57题setX,setY都是私有的不可能由线程直接调用,因此C是错的
wangsheng1028 2003-06-26
  • 打赏
  • 举报
回复
29好像答案是有问题的!
如答案所说编译过不去的!
LazyFarmer 2003-06-26
  • 打赏
  • 举报
回复
55题,你的答案是不是错了呀。应该是C、D吧
eastconquer 2003-06-25
  • 打赏
  • 举报
回复
29 题 byte[] arry1,arry2[] EQUAL byte arry1[],arry2[][] UNDERSTAND?
I passed the exam on monday!
It have 11、29、55、57、74.
If you can't understand it's answer,just memory it !

51,410

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧