分享
 
 
 

310-025 scjp exam dumps 06/10/02

王朝other·作者佚名  2008-05-31
窄屏简体版  字體: |||超大  

I prepared by using "Complete Java 2 Certification Study Guide" for Simon Roberts (Sybex).

1. public class x implements Runnable{

private int x;

private int y;

public static void main(String args[] ){

x that = new x();

(new Thread(that)).start();

(new Thread(that)).start();

}

public synchronized void run(){

for( ; ; ){

x++;

y++;

System.out.Println("x=" + x + ", y=" +y);

}

}

a. An error at line 11

b. An error at line 7, 8

c. The program prints pairs of values for x and y that might not always be the same on the same line (for example "x=2, y=1")

d. The program prints pairs of values for x and y that are always the same on the same line (for example "x=1, y=1") in addition, each value appears twice (for example "x=1, y=1" followed by "x=1, y=1")

e. The program prints pairs of values for x and y that are always the same on the same line (for example "x=1, y=1") in addition, each value appears only once (for example "x=1, y=1", followed by "x=2, y=2)

Answer: E (my; C)

2.

1. public class x{

2. public object m(){

3. Object o=new Float(2.14F);

4. Object [] oa=new Object[1];

5. oa[0]=o;

6. o=null;

7. return o;

8. } // end m() method.

9. }

When is the Float object creation in line 3 eligible for garbage collection ?

a. just after line 5

b. just after line 6

c. just after line 7 (that is , as the method returns)

d. just after line 8 (that is, as the method ends)

Answer: I choose d which was wrong. I think ; b

3.

1. abstract class AbstractIt{

2. abstract float getFloat();

3. }

4. public class AbstractTest extends AbstractIt{

5. private float f1 = 1.0f;

6. private float getFloat(){return f1}

7. }

what result?

a. compile sUCcess

b. An error at line 6

c. An error at line 4

d. An error at line 2

Answer:

b

getFloat() in AbstractTest cannot override getFloat() in AbstractIt; attempting to assign weaker Access privileges; was package

4.

import java.io.IOException;

public class ExceptionTest{

public static void main(String[] args){

try{

methodA();

}catch(IOException io){

System.out.println("caught IOException");

}catch(Exception e){

System.out.println("caught Exception");

}

}

public void methodA(){

throw new IOException();

}

}

what result?

a. The code will not compile

b. Output is "caught Exception"

c. Output is "caught IOException"

d. The program execute nomally whihout print a message

Answer:

a

non-static method methodA() cannot be refereced from a static context.

5.

public class Foo{

public static void main(String[] args)[

try{ return;}

finally{ System.out.println("Finally");}

]

}

what result?

a. Print nothing

b. Print "Finally"

c. Not compiled and will Exception thrown

d. Not compile because catch block missing

Answer:

b

6.

public class Foo{

public static void main(String[] args){

StringBuffer a = new StringBuffer("A");

StringBuffer b = new StringBuffer("B");

operate(a,b);

System.out.println(a + "," + b);

}

static void operate(StringBuffer x,StringBuffer y){

y.append(x);

y = x;

} // end operate

}

What print?

a. "A,B" b. "A,A" c. "B,B"

d. "AB,B" e. "AB,AB" f, "A,AB"

Answer: F ans: A,BA

7.

1. class A implements Runnable {

2. int I;

3. public void run () {

4. try {

5. Thread.sleep(5000);

6. i=10;

7. }catch(InterruptedException e) {}

8. }

9. }

10.

11. public class Test {

12. public static void main (String args[]) {

13. try {

14. A a = new A();

15. Thread t = new Thread(a);

16. t.start();

17.

18. int j= a.i;

19.

20. }catch (Exception e) {}

21. }

22. }

Which statement at line 17 will ensure that j=10 at line 19

A. a.wait(); B. t.wait(); C. t.join(); D. t.yield();

E. t.notify(); F. a.notify(); G. t.interrupt();

Answer: C

8.

1. public class SyncTest {

2. private int x;

3. private int y;

4. private synchronized void set X (int i){ x=i; }

5. private synchronized void set Y (int i){ y=i; }

6. public void setXY (int i) {set X(i); set Y(i); }

7. public synchronized boolean check() {return X != Y; }

8. }

Under which conditions will check() return when called from a different class. Choose one

A. check() can never return true

B. check() can return true when set XY is called by multiple threads

C. check() can true when multiple threads call set X and set Y separately

D. check() can only return true if synchTest is changed to allow x and y to be set separately

Answer:

I choose D

9.

Which is a method of the MouseMotionListener interface

A. public void mouseDragged(MouseEvent)

B. public boolean mouseDragged(MouseEvent)

C. public void mouseDragged(MouseMotionEvent)

D. public boolean mouseDragged(MouseMotionEvent)

E. public boolean mouseDragged(MouseMotionEvent)

Answer:

A

10.

AnInterface is an interface.

AnAdapter0 is an non-Abstract, not-final with zero argument construter

AnAdapter1 is an non-Abstract, not-final without zero argument construter, but with a constructor to take one argument.

Which will create Anonymous class (choose two)

a}AnAdapter0 a = new AnAdapter0();

b}AnAdapter1 a = new AnAdapter1();

c}AnAdapter0 a = new AnAdapter0(5);

d}AnAdapter1 a = new AnAdapter1(5);

e}AnInterface a = new AnInterface(5);

Ans:

a and d are correct. B, c and e are wrong.

11.

What is true about java.util.Arraylist (choose one)

a)The elements in the collection are ordered

b)The collection is guaranteed to be immutable.

c)The elements in the collection are guaranteed to be unique.

d)The elements in the collection are accessed using a unique key

e)The elements in the collection are guaranteed to be synchronized

Answer:

A is correct.

ArrayList implemnets all optional List operation.

b is wrong because lists typically allow duplicate elements. C is wrong this is Set facility. D is wrong because this is Map facility.

E is wrong, Note that this implementation is not synchronized. If multiple threads access an ArrayList instance concurrently, and at least one of the threads modifies the list structurally, it must be synchronized externally ( refer documents )

12.

1.class A{

2. public int getNumber(int a){

3. return a +1;

4. }

5.}

6.class B extends A{

7. public int getNumber(int a){

8. return a + 2;

9. }

10. public static void main(String args[]){

11. B b = new B();

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有