java程序員認(rèn)證試題練習(xí)
人生像攀登一座山,而找尋出路,卻是一種學(xué)習(xí)的過(guò)程,我們應(yīng)當(dāng)在這過(guò)程中,學(xué)習(xí)穩(wěn)定冷靜,學(xué)習(xí)如何從慌亂中找到生機(jī)。以下是小編為大家搜索整理的java程序員認(rèn)證試題練習(xí),希望能給大家?guī)?lái)幫助!更多精彩內(nèi)容請(qǐng)及時(shí)關(guān)注我們應(yīng)屆畢業(yè)生考試網(wǎng)!
一.說(shuō)明:(真實(shí)考試)
1.考試形式:網(wǎng)絡(luò)計(jì)算機(jī)
2.考題形式:多選,單選,簡(jiǎn)答
3.題量:60
4.考試時(shí)間:120分鐘
二.模擬題
1.Which statement about the garbage collection mechanism are true?
A. Garbage collection require additional programe code in cases where multiple threads are running.
B. The programmer can indicate that a reference through a local variable is no longer of interest.
C. The programmer has a mechanism that explicity and immediately frees the memory used by Java objects.
D. The garbage collection mechanism can free the memory used by Java Object at explection time.
E. The garbage collection system never reclaims memory from objects while are still accessible to running user threads.
2. Give the following method:
1) public void method( ){
2) String a,b;
3) a=new String(“hello world”);
4) b=new String(“game over”);
5) System.out.println(a b ”ok”);
6) a=null;
7) a=b;
8) System.out.println(a);
9) }
In the absence of compiler optimization, which is the earliest point the object a refered is definitely elibile to be garbage collection.
A. before line 3
B.before line 5
C. before line 6
D.before line 7
E. Before line 9
3. In the class java.awt.AWTEvent,which is the parent class upon which jdk1.1 awt events are based there is a method called getID which phrase accurately describes the return value of this method?
A. It is a reference to the object directly affected by the cause of the event.
B. It is an indication of the nature of the cause of the event.
C. It is an indication of the position of the mouse when it caused the event.
D. In the case of a mouse click, it is an indication of the text under the mouse at the time of the event.
E. It tells the state of certain keys on the keybord at the time of the event.
F. It is an indication of the time at which the event occurred.
4. Which statement about listener is true?
A. Most component allow multiple listeners to be added.
B. If multiple listener be add to a single component, the event only affected one listener.
C. Component don?t allow multiple listeners to be add.
D. The listener mechanism allows you to call an addXxxxListener method as many times as is needed, specifying as many different listeners as your design require.
5.Give the following code:
public class Example{
public static void main(String args[] ){
int l=0;
do{
System.out.println(“Doing it for l is:” l);
}while(--l>0)
System.out.println(“Finish”);
}
}
Which well be output:
A. Doing it for l is 3
B. Doing it for l is 1
C. Doing it for l is 2
D. Doing it for l is 0
E. Doing it for l is ?C1
F. Finish見(jiàn)1-5題答案
答案及詳細(xì)分析:
1。B、E
JAVA的垃圾回收機(jī)制是通過(guò)一個(gè)后臺(tái)系統(tǒng)級(jí)線程對(duì)內(nèi)存分配情況進(jìn)行跟蹤實(shí)現(xiàn)的,對(duì)程序員來(lái)說(shuō)是透明的,程序員沒(méi)有任何方式使無(wú)用內(nèi)存顯示的、立即的被釋放。而且它是在程序運(yùn)行期間發(fā)生的。
答案B告訴我們程序員可以使一個(gè)本地變量失去任何意義,例如給本地變量賦值為“null”;答案E告訴我們?cè)诔绦蜻\(yùn)行期間不可能完全釋放內(nèi)存。
2。D
第6行將null賦值給a以后,a以前保存的引用所指向的內(nèi)存空間就失去了作用,它可能被釋放。所以對(duì)象a可能最早被垃圾回收是在第7行以前,故選擇D選項(xiàng)。
3。B
請(qǐng)查閱JAVA類庫(kù)。getID方法的返回值是“event type”。在認(rèn)證考試中,總會(huì)有類似的書(shū)本以外的知識(shí),這只能靠多實(shí)踐來(lái)增長(zhǎng)知識(shí)了。
4。A、D
控件可以同時(shí)使用多個(gè)“addXxxxListener”方法加入多個(gè)監(jiān)測(cè)器。并且當(dāng)多個(gè)監(jiān)測(cè)器加入到同一控件中時(shí),事件可以響應(yīng)多個(gè)監(jiān)測(cè)器,響應(yīng)是沒(méi)有固定順序的。
5。D、F
本題主要考察考生對(duì)流程控制的掌握情況。這是當(dāng)型循環(huán),條件為真執(zhí)行,條件為假則退出。循環(huán)體至少執(zhí)行一次,故會(huì)輸出D。循環(huán)體以外的語(yǔ)句總會(huì)被執(zhí)行,故輸出F。
6. Give the code fragment:
1) switch(x){
2) case 1:System.out.println(“Test 1”);break;
3) case 2:
4) case 3:System.out.println(“Test 2”);break;
5) default:System.out.println(“end”);
6) }
which value of x would cause “Test 2” to the output:
A. 1
B. 2
C. 3
D. default
7. Give incompleted method:
1)
2) { if(unsafe()){//do something…}
3) else if(safe()){//do the other…}
4) }
The method unsafe() well throe an IOException, which completes the method of declaration when added at line one?
A. public IOException methodName()
B. public void methodName()
C. public void methodName() throw IOException
D. public void methodName() throws IOException
E. public void methodName() throws Exception
8. Give the code fragment:
if(x>4){
System.out.println(“Test 1”);}
else if (x>9){
System.out.println(“Test 2”);}
else {
System.out.println(“Test 3”);}
Which range of value x would produce of output “Test 2”?
A. x<4
B. x>4
C. x>9
D. None
9. Give the following method:
public void example(){
try{
unsafe();
System.out.println(“Test1”);
}catch(SafeException e){System.out.println(“Test 2”);
}finally{System.out.println(“Test 3”);}
System.out.println(“Test 4”);
Which will display if method unsafe () run normally?
A. Test 1
B. Test 2
C. Test 3
D. Test 4
10. Which method you define as the starting point of new thread in a class from which new the thread can be excution?
A. public void start()
B. public void run()
C. public void int()
D. public static void main(String args[])
E. public void runnable()
6-10答案:
6。B.C
在開(kāi)關(guān)語(yǔ)句中,標(biāo)號(hào)總是不被當(dāng)做語(yǔ)句的一部分,標(biāo)號(hào)的作用就是做為條件判斷而已,一旦匹配成功,就執(zhí)行其后的語(yǔ)句,一直遭遇break語(yǔ)句為止。(包括default語(yǔ)句在內(nèi))
7。D、F
IOException異常類是Exception的子類。根據(jù)多態(tài)性的定義,IOException對(duì)象也可以被認(rèn)為是Exception類型。還要注意在方法聲明中拋出異常應(yīng)用關(guān)鍵字“throws”。
8。D
只有兩種情況:大于4時(shí)輸出“Test1”,小于等于4時(shí)輸出“Test3”。
9。A、C、D
在正常情況下,打印Test1、Test3、Test4;在產(chǎn)生可捕獲異常時(shí)打印Test2、Test3、Test4;在產(chǎn)生不可捕獲異常時(shí),打印Test3,然后終止程序。注意finally后面的語(yǔ)句總是被執(zhí)行。
10。B
線程的執(zhí)行是從方法“run( )”開(kāi)始的,該方法是由系統(tǒng)調(diào)用的。程序員手工調(diào)用方法start(),使線程變?yōu)榭蛇\(yùn)行狀態(tài)。
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{}
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
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
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]
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…}11-15答案:
11。A
此題考查內(nèi)部類及關(guān)鍵字“super”的用法。內(nèi)部類不能與外部類同名。另外,當(dāng)B繼承A時(shí),A中的構(gòu)造函數(shù)是帶參數(shù)的,B中缺省構(gòu)造函數(shù)的函數(shù)體為空;而JAVA編譯器會(huì)為空構(gòu)造函數(shù)體自動(dòng)添加語(yǔ)句“super();”調(diào)用父類構(gòu)造函數(shù),更進(jìn)一步是調(diào)用父類的參數(shù)為空的構(gòu)造函數(shù)。而父類中沒(méi)有參數(shù)為空的`構(gòu)造函數(shù)。
12。A
此關(guān)鍵字可以在兩個(gè)線程同時(shí)試圖訪問(wèn)某一數(shù)據(jù)時(shí)避免數(shù)據(jù)毀損。
13。C
當(dāng)一個(gè)類中未顯式定義構(gòu)造函數(shù)時(shí),缺省的構(gòu)造函數(shù)是以類名為函數(shù)名,參數(shù)為空,函數(shù)體為空。雖然父類中的某一構(gòu)造函數(shù)有字符串參數(shù)s,但是子類繼承父類時(shí)并不繼承構(gòu)造函數(shù),所以它只能使用缺省構(gòu)造函數(shù)。故在第11行出錯(cuò)。
14。A、B
注意,題中問(wèn)的是如何正確聲明一個(gè)一維數(shù)組,并非實(shí)例化或者初始化數(shù)組
15。A、E
X處可以是一個(gè)輸入,包的定義,類的定義。由于常量或變量的聲明只能在類中或方法中,故不能選擇C;由于在一個(gè)文件中只能有一個(gè)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
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
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
19.Which declares for native method in a java class corrected?
A. public native void method(){}
B. public native void method();
C. public native method();
D. public void method(){native;}
E. public void native method();
20. Which modifer should be applied to a declaration of a class member variable for the value of variable to remain constant after the creation of the object?
16-20答安:
16。B
靜態(tài)方法除了自己的參數(shù)外只能直接訪問(wèn)靜態(tài)成員。訪問(wèn)非靜態(tài)成員,必須先實(shí)例化本類的一個(gè)實(shí)例,再用實(shí)例名點(diǎn)取。
17。A、B、D
polygon的頂點(diǎn)信息存放在Vector類型的對(duì)象內(nèi)部,color定義為Color,length和width定義為int。
注意,這是考試中常見(jiàn)的題型。
18。C
此題考點(diǎn)是高級(jí)訪問(wèn)控制。請(qǐng)考生查閱高級(jí)訪問(wèn)控制說(shuō)明表格。
19。B
native關(guān)鍵字指明是對(duì)本地方法的調(diào)用,在JAVA中是只能訪問(wèn)但不能寫(xiě)的方法,它的位置在訪問(wèn)權(quán)限修飾語(yǔ)的后面及返回值的前面。
20。final
定義常量的方法是在變量定義前加final關(guān)鍵字。
21. Which is the main() method return of a application?
A. String
B. byte
C. char
D. void
22. Which is corrected argument of main() method of application?
A. String args
B. String ar[]
C. Char args[][]
D. StringBuffer arg[]
23. “The Employee object is a person, An Employee has appointment store in a vector, a hire date and a number of dependent”
short answer: use shortest statement declare a class of Employee.
24. Give the following class defination inseparate source files:
public class Example{
public Example(){//do something}
protected Example(int i){//do something}
protected void method(){//do something}
}
public class Hello extends Example{//member method and member variable}
Which methods are corrected added to the class Hello?
A. public void Example(){}
B. public void method(){}
C. protected void method(){}
D. private void method(){}
25. Float s=new Float(0.9F);
Float t=new Float(0.9F);
Double u=new Double(0.9);
Which expression?s result is true?
A. s==t
B. s.equals(t)
C. s==u
D. t.equals(u)
21-15答案:
21。D
main()方法沒(méi)有返回值,所以必須用void修飾。main()方法的返回值不能任意修改。
22。B
main()方法的參數(shù)是字符串?dāng)?shù)組,參數(shù)名可以任意定義。
23。public class Employee extends Person
這也是真實(shí)考試中常見(jiàn)的一種題型。要注意題目敘述中“is a”表示 “extends”的含義。
24。A、B、C
考察的知識(shí)點(diǎn)是方法覆蓋,其中要注意的是方法覆蓋時(shí),子類方法的訪問(wèn)權(quán)限不能小于父類方法的訪問(wèn)權(quán)限。另外,選項(xiàng)A并不是父類構(gòu)造函數(shù),它是子類中的新方法。
25。A、B
考察“==”及方法“equals()”的用法。注意以下幾點(diǎn)區(qū)別:
1) 引用類型比較引用;基本類型比較值。
2) equals()方法只能比較引用類型,“==”可比較引用及基本類型。
3) 當(dāng)用equals()方法進(jìn)行比較時(shí),對(duì)類File、String、Date及封裝類(Wrapper Class)來(lái)說(shuō),是比較類型及內(nèi)容。
4) 用“==”進(jìn)行比較時(shí),符號(hào)兩邊的數(shù)據(jù)類型必須一致(可相互轉(zhuǎn)換的基本類型除外),否則編譯出錯(cuò)。
【java程序員認(rèn)證試題練習(xí)】相關(guān)文章: