作者DavyBlue (ArssertionError)
看板java
标题[SCJP] 猛虎後面题目勘误 欢迎有心者补完
时间Fri Mar 16 21:02:47 2007
这几题是目前问题比较大的
==============================================================================
题目77
class Inner{
private int x;
public void setX(int x){this.x = x}
public int getX( return x;)
}
class Outer{
private Inner y;
public void setY(Inner y){ this.y = y }
public Inner getY() { return y; }
}
public class Gamma {
public static void main(String[] args){
Outer o = new Outer;
Inner i = new Inner;
int n = 10;
i.setX(n);
o.setY(i);
//insert code here
System.out.println(o.getY().getX());
}
}
Which three code fragments,added individually at line 29, produce the output
100?(choose three)
答案是:
B. setX(100);
C. getY().setX(100);
F. i = new Inner();i.setX(100);o.setY(i);
这BC两个答案 真是让人百思不得其解
原来在static method里面可以这样存取non-static?
好像少了"i."吧....
==============================================================================
第79题
11. public static void test(String str){
12. if(str == null | str.length() == 0){
13. system.out.println("String is empty");
14. }else{
15. system.out.println("String is not empty");
16. }
17. }
.
.
.
31. test(null);
答案是执行时抛出例外...?
第一 system他的s小写
第二 就算S是手残打错 解说竟然说 "main()方法中资料型别应为String[]"
我这题怎麽找都找不到main....
==============================================================================
第80题
要我们从树状图中找出哪一个是正确的
com.foo.bar.Dog
com.foo.bar.blatz.Book
com.bar.Car
com.bar.blatz.Sun
正解竟然是这样画的
|
|bar----blatz--Sun.class
| |
| ---Car.class
|
|com--foo--bar----baltz--Book.class
|
---Dog.class
这哪可能合理....
==============================================================================
试题83
这题就是之前有板友问的GC那题 就不再赘述
==============================================================================
试题97
解析根本在乱写的一题
import static java.lang.System.out;
public class Yippee{
public static void go(Long n){out.println("Long ");}
public static void go(Short n){out.println("Short ");}
public static void go(int n){out.println("int ");}
public static void main(String[] args){
short y = 6;
long z = 7;
go(y);
go(z);
}
}
what is the result?
这题解答我自己写 他的我不想说了 不知所云
当main执行到go(y)时 因为y是short 在引数优先权来说
相同型别>自动转型>自动拆装/包装>var-arg
故会显示int
同理 当main执行到go(z)
因自动转型只能把小的放进大的
所以不能传入int 故自动包装成Long 显示Long
答案: int Long
==============================================================================
试题111
这题是我搞不懂一个选项
题目是这样的
public void takeList(List<? extends String> list){
//insert code here
}
这是拖曳配对题
其中一个
list.add("Foo");要跟编译错误配...?
理由是 "不保证list之前放置的内容是String"
奇怪 这种题目不是要我们假设除了看的到的其他都是正确的...
==============================================================================
试题122
这题题目我不打了
答案是D没错
解说太好笑了
选项: A: The code will compile without changes.
解析: A: 错误 此题可以编译成功
==============================================================================
试题138
这题也很好玩
题目本身编号从1~7
答案是D:compilation fails because of an error in line 13.
经过我聪明的大脑分析後 应该是第3行
以及 解说中 "等号(==)" 的()里面应该只有一个=
我从来不知道"=="叫做等号...
==============================================================================
试题140
答案D 选项不知去向
要我自己掰题目? 饶了我吧
==============================================================================
试题143
答案是C
不过解说的最後面说答案选D
到底是要我选C还选D 我好乱阿....
(好吧偷偷告诉你 正解是C没错)
==============================================================================
试题145
选项C应该是Line "3"不是Line "2"
不然解说在说啥我又看不懂了
==============================================================================
试题154
class One{
void foo(){}
}
class Two extends One{
//insert method here
}
which three methods inserted individually at the line will correctly class Two?
(choose three)
A. int foo(){/*....*/}
B. void foo(){/*.....*/}
C. public foo(){/*....*/}
D. private foo(){/*....*/}
E. protected foo(){/*....*/}
答案 BCE
很抱歉 我怎麽看都看不出来为啥有CE
没有回传值没有回传值没有回传值没有回传值没有回传值没有回传值没有回传值
又不是建构子...
好吧 我相信他是忘了加void上去
==============================================================================
试题168
还真是一路发阿 发到发疯了
这题拖曳题的选项又消失了 被鬼抓走了吗?
谁去把他找回来?
==============================================================================
今天先到此为止 在bbs上打这种东西真的会死人...
希望有帮到大家的忙
--
版主要我补上ISBN...
JAVA认证SCJP--猛虎出闸/段维瀚着
碁峰资讯
ISBN 986-421-880-8(平装附光碟)
312.932J3 94021738
2006年4月初版二刷
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 203.121.240.81
※ 编辑: DavyBlue 来自: 203.121.240.81 (03/16 21:16)