SCJP 6.0 認證教戰手冊 黃彬華著 碁峰出版
書名:SCJP 6.0 認證教戰手冊 作者:黃彬華
完全擬真試題 101-200(共 244 題)
第101題
Given:
10. package com.sun.scjp;
11. public class Geodetics {
12. public static final double DIAMETER = 12756.32; //kilometers
13. }
Which two correctly access the DIAMETER member of the Geodetics class? (Choose two.)
A. import com.sun.scjp.Geodetics;
public class TerraCarta{
public double halfway()
{return Geodetics.DIAMETER/2.0;}
B. import static com.sun.scjp.Geodetics;
public class TerraCarta{
public double halfway(){return DIAMETER/2.0;}}
C import static com.sun.scjp.Geodetics.*;
public class TerraCarta{
public double halfway(){return DIAMETER/2.0;}}
D. package com.sun.scjp;
public class TerraCarta{
public double halfway(){return DIAMETER/2.0;}}
答案:AC
參考:8-2 方法種類與呼叫方式
第102題
Given:
10. interface Foo{int bar();}
11. public class Sprite{
12. public int fubar(Foo foo){return foo.bar();}
13. public void testFoo(){
14. fubar(
15. //insert code here
16. );
17. }
18. }
Which code, inserted at line 15, allows the class Sprite to compile?
A. Foo{public int bar(){return 1;}}
B. new Foo{public int bar(){return 1;}}
C. new Foo(){public int bar(){return 1;}}
1