| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1290 人关注过本帖
标题:[讨论][求助]几道SCJP的考题请教大家
只看楼主 加入收藏
musicyxy
Rank: 1
等 级:新手上路
帖 子:120
专家分:0
注 册:2004-8-14
收藏
 问题点数:0 回复次数:18 
[讨论][求助]几道SCJP的考题请教大家

有些题目我翻译的可能不是很准确,希望大家解答的同时给于翻译。还有大家会哪个就答哪个,我们可以在一起讨论,我相信群众中蕴藏着大智慧。

(1)Which statement is true?
下面哪种说法是正确的?

A. Memory is reclaimed by calling Runtime.gc(). 调用Runtime.gc()方法时内存会被回收。
B. Objects are not collected if they are accessible from live threads. 存活的线程中的对象是不会被回收的。
C. Objects that have finalize() methods are never garbage collected. 对象调用finalize()方法绝对不被垃圾回收。
D. Objects that have finalize() methods always have their finalize() methods called before
the program ends. 类的finalize()方法总是在程序结束以前被调用。
E. An OutOfMemory error is only thrown if a single block of memory cannot be found
that is large enough for a particular requirement.


(2)
1. class A {
2. A() { }
3. }
4.
5. class B extends A {
6. }
Which two statements are true? (Choose two)
哪两个说法是正确的?
A. Class B’s constructor is public. 类B的构造方法是公有的。
B. Class B’s constructor has no arguments. 类B的构造方法
C. Class B’s constructor includes a call to this().
D. Class B’s constructor includes a call to super().

(3)

You want a class to have access to members of another class in the same package. Which
is the most restrictive access that accomplishes this objective?
你在一个包中让一个类去访问另一个类的成员。哪一种最能达到限制访问的目的?

A. public
B. private
C. protected
D. transient
E. default access

(4)

Which statement is true?
哪一个说法是正确的?

A. Assertions can be enabled or disabled on a class-by-class basis.
B. Conditional compilation is used to allow tested classes to run at full speed.
C. Assertions are appropriate for checking the validity of arguments in a method.
D. The programmer can choose to execute a return statement or to throw an exception if
an assertion fails.

搜索更多相关主题的帖子: 考题 SCJP 
2006-05-10 19:08
Grace_TT
Rank: 1
等 级:新手上路
威 望:1
帖 子:324
专家分:0
注 册:2005-12-21
收藏
得分:0 
我觉得:
1。B
2。B、D
3.E
4.不知道
2006-05-10 20:45
musicyxy
Rank: 1
等 级:新手上路
帖 子:120
专家分:0
注 册:2004-8-14
收藏
得分:0 
你为什么这么觉得呢?

2006-05-10 21:02
Grace_TT
Rank: 1
等 级:新手上路
威 望:1
帖 子:324
专家分:0
注 册:2005-12-21
收藏
得分:0 
1.我记得好像只有对象不再被引用的时候才会被回收。
2。B没有自定义构造函数,那它只能调用父类的了。
如果构造函数没有参数的话,子类利用super()显示调用父类的构造函数和默认调用是一样的,也就是你写不写super()效果是一样的。
3。public、protected、default access 都能达到目的,但是the most restrictive access 的话,我觉得应该是default access 了。

嘿嘿,说错了的话,大家要指正呀!
2006-05-10 21:22
musicyxy
Rank: 1
等 级:新手上路
帖 子:120
专家分:0
注 册:2004-8-14
收藏
得分:0 

楼上的朋友:
第(1)题我们的观点相同,但是E选项我翻译不好。
第(2)题, has no arguments是什么意思呢?
第(3)题中,public也能达到限制访问的目的吗?

第(4)题,有人能帮助翻译一下吗?




2006-05-10 21:58
Grace_TT
Rank: 1
等 级:新手上路
威 望:1
帖 子:324
专家分:0
注 册:2005-12-21
收藏
得分:0 

第二题的意思我是猜的,我感觉好像就是说B的构造函数没有被定义的意思。其实,如果单纯从做题的角度来看,这个题用排除法做也可以,A、C不对,那就只有B、D了。

第(3)题中,public也能达到限制访问的目的吗?
--------public也是访问控制符的一种呀。

You want a class to have access to members of another class in the same package. --------这句话才是 this objective 吧。

2006-05-10 22:12
Grace_TT
Rank: 1
等 级:新手上路
威 望:1
帖 子:324
专家分:0
注 册:2005-12-21
收藏
得分:0 
呵呵,再猜一次:
has no arguments----可能是没有方法体的意思
2006-05-10 22:34
musicyxy
Rank: 1
等 级:新手上路
帖 子:120
专家分:0
注 册:2004-8-14
收藏
得分:0 
public 在访问控制修饰符中是权限最宽的一个,是允许跨包访问的,所以用public来修饰起不到限制访问的目的。还有我觉得(3)的答案应该是B,因为default access并没有private的限制严格,所以最小的访问权限应该是private。


2006-05-11 15:21
Grace_TT
Rank: 1
等 级:新手上路
威 望:1
帖 子:324
专家分:0
注 册:2005-12-21
收藏
得分:0 

private只能在同一个类中被访问,同一个包中的其它类不能访问它。

You want a class to have access to members of another class in the same package.
-------------其中有another class,你要是用private,是不能访问的。

2006-05-11 15:43
musicyxy
Rank: 1
等 级:新手上路
帖 子:120
专家分:0
注 册:2004-8-14
收藏
得分:0 
搞不懂了,它的目的不就是限制访问吗?

2006-05-11 19:23
快速回复:[讨论][求助]几道SCJP的考题请教大家
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015855 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved