中日韩va无码中文字幕_亚洲va中文字幕无码久_又粗又大又黄又刺激的免费视频_成年人国产免费网站

當(dāng)前位置:

JAVA認(rèn)證歷年真題:SCJP考試真題和解析6

發(fā)表時間:2014/4/21 9:54:55 來源:互聯(lián)網(wǎng) 點(diǎn)擊關(guān)注微信:關(guān)注中大網(wǎng)校微信
關(guān)注公眾號

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

此題考查內(nèi)部類及關(guān)鍵字“super”的用法。內(nèi)部類不能與外部類同名。另外,當(dāng)B繼承A?xí)r,A中的構(gòu)造函數(shù)是帶參數(shù)的,B中缺省構(gòu)造函數(shù)的函數(shù)體為空;而JAVA編譯器會為空構(gòu)造函數(shù)體自動添加語句“super();”調(diào)用父類構(gòu)造函數(shù),更進(jìn)一步是調(diào)用父類的參數(shù)為空的構(gòu)造函數(shù)。而父類中沒有參數(shù)為空的構(gòu)造函數(shù)。

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

此關(guān)鍵字可以在兩個線程同時試圖訪問某一數(shù)據(jù)時避免數(shù)據(jù)毀損。

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

當(dāng)一個類中未顯式定義構(gòu)造函數(shù)時,缺省的構(gòu)造函數(shù)是以類名為函數(shù)名,參數(shù)為空,函數(shù)體為空。雖然父類中的某一構(gòu)造函數(shù)有字符串參數(shù)s,但是子類繼承父類時并不繼承構(gòu)造函數(shù),所以它只能使用缺省構(gòu)造函數(shù)。故在第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

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

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

靜態(tài)方法除了自己的參數(shù)外只能直接訪問靜態(tài)成員。訪問非靜態(tài)成員,必須先實(shí)例化本類的一個實(shí)例,再用實(shí)例名點(diǎn)取。

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的頂點(diǎn)信息存放在Vector類型的對象內(nèi)部,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

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

相關(guān)鏈接JAVA認(rèn)證考試報(bào)考指南  考試論壇 考試知道   考試動態(tài)

(責(zé)任編輯:fky)

2頁,當(dāng)前第1頁  第一頁  前一頁  下一頁
最近更新 考試動態(tài) 更多>