精品91麻豆免费免费国产在线_男女福利视频_国产一区二区三区小向美奈子_在教室里和同桌做校园h文

當前位置:

JAVA認證歷年真題:SCJP考試真題和解析6

發表時間:2014/4/21 9:54:55 來源:互聯網 點擊關注微信:關注中大網校微信
關注公眾號

11.Given the following class definition:

class A{

protected int i;

A(int i){

this.i=i;

}

}

which of the following would be a valid inner class for this class?

Select all valid answers:

A. class B{

}

B. class B extends A{

}

C. class B extends A{

B(){System.out.println(“i=”+i);}

}

D. class B{

class A{}

}

E. class A{}

11。A

此題考查內部類及關鍵字“super”的用法。內部類不能與外部類同名。另外,當B繼承A時,A中的構造函數是帶參數的,B中缺省構造函數的函數體為空;而JAVA編譯器會為空構造函數體自動添加語句“super();”調用父類構造函數,更進一步是調用父類的參數為空的構造函數。而父類中沒有參數為空的構造函數。

12. Which modifier should be applied to a method for the lock of object this to be obtained prior to excution any of the method body?

A. synchronized

B. abstract

C. final

D. static

E. public

12。A

此關鍵字可以在兩個線程同時試圖訪問某一數據時避免數據毀損。

13. The following code is entire contents of a file called Example.java,causes precisely one error during compilation:

1) class SubClass extends BaseClass{

2) }

3) class BaseClass(){

4) String str;

5) public BaseClass(){

6) System.out.println(“ok”);}

7) public BaseClass(String s){

8) str=s;}}

9) public class Example{

10) public void method(){

11) SubClass s=new SubClass(“hello”);

12) BaseClass b=new BaseClass(“world”);

13) }

14) }

Which line would be cause the error?

A. 9 B. 10 C. 11 D.12

13。C

當一個類中未顯式定義構造函數時,缺省的構造函數是以類名為函數名,參數為空,函數體為空。雖然父類中的某一構造函數有字符串參數s,但是子類繼承父類時并不繼承構造函數,所以它只能使用缺省構造函數。故在第11行出錯。

14. Which statement is correctly declare a variable a which is suitable for refering to an array of 50 string empty object?

A. String [] a

B. String a[]

C. char a[][]

D. String a[50]

F. Object a[50]

14。A、B

注意,題中問的是如何正確聲明一個一維數組,并非實例化或者初始化數組

15. Give the following java source fragement:

//point x

public class Interesting{

//do something

}

Which statement is correctly Java syntax at point x?

A. import java.awt.*;

B.package mypackage

C. static int PI=3.14

D. public class MyClass{//do other thing…} E. class MyClass{//do something…}

15。A、E

X處可以是一個輸入,包的定義,類的定義。由于常量或變量的聲明只能在類中或方法中,故不能選擇C;由于在一個文件中只能有一個public類,故不能選擇D。

16. Give this class outline:

class Example{

private int x;

//rest of class body…

}

Assuming that x invoked by the code java Example, which statement can made x be directly accessible in main() method of Example.java?

A. Change private int x to public int x

B. change private int x to static int x

C. Change private int x to protected int x

D. change private int x to final int x

16。B

靜態方法除了自己的參數外只能直接訪問靜態成員。訪問非靜態成員,必須先實例化本類的一個實例,再用實例名點取。

17. the piece of preliminary analsis work describes a class that will be used frequently in many unrelated parts of a project

“The polygon object is a drawable, A polygon has vertex information stored in a vector, a color, length and width.”

Which Data type would be used?

A. Vector

B. int

C. String

D. Color

E. Date

17。A、B、D

polygon的頂點信息存放在Vector類型的對象內部,color定義為Color,length和width定義為int。

注意,這是考試中常見的題型。

18. A class design requires that a member variable should be accessible only by same package, which modifer word should be used?

A. protected

B. public

C. no modifer

D. private

18。C

此題考點是高級訪問控制。請考生查閱高級訪問控制說明表格。

相關鏈接JAVA認證考試報考指南  考試論壇 考試知道   考試動態

(責任編輯:fky)

2頁,當前第1頁  第一頁  前一頁  下一頁
最近更新 考試動態 更多>

考試科目