10年JAVA模擬試題A_第1頁
10年JAVA模擬試題A_第2頁
10年JAVA模擬試題A_第3頁
10年JAVA模擬試題A_第4頁
10年JAVA模擬試題A_第5頁
已閱讀5頁,還剩8頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、10年JAVA模擬試題A一、單項選擇題( 分)135每小題1分,3650每小題2分,共651. Java虛擬機(JVM )在運行JAVA代碼時,不會進行的操作是A )加載代碼B)校驗代碼C)編譯代碼 D )執(zhí)行代碼2. JAVA程序的并發(fā)機制是A) 多線程 B)多接口C)多平臺D)多態(tài)性3. 在方法內部使用,代表對當前對象自身引用的關鍵字是A) super B)ThisD)SuperD)this4. 對鼠標點擊按鈕操作進行事件處理的接口是A) MouseListenerB) WindowsListenerC) ActionListenerD) KeyListener5. AWT中用來表示顏色的

2、類是A) FontB) Color6. Java中屬于跳轉語句的是A) tryB) catch7. 下面說法哪個是正確的()A ) Applet可以訪問本地文件C) socket類在 javaang 中C)PanelD)DialogC) finallyD ) breakB)對static方法的調用需要類實例D ) 127.0.0.1地址代表本機&下列哪個方法可用于創(chuàng)建一個可運行的類 ()A ) public class X implements Runable public void run()B ) public class X implements Thread public void r

3、un()C) public class X implements Thread public int run()D ) public class X implements Runable protected void run()9. Java編程所必須的默認引用包為()D)以上都不是A ) java.sys包B) javaang 包C) java.new 包10. Java Applet源程序文件的擴展名為()。A ) .javaB) .class C) .html D) .exe11. 設a = 3,則表達式(-a)a的值是()。A ) 16B ) 8C ) 24D) 1212. 在Java

4、 Applet程序用戶自定義的Applet子類中,一般需要重載父類的()方法來完成主類實例的初始化工作。A ) start( )B) stop( ) C) init( ) D) paint()13. 創(chuàng)建一個標識有“關閉”按鈕的語句是()。A ) TextField b = new TextField( “關閉”);B ) Label b = new Label( “關閉”);C) Checkbox b = new Checkbox關閉”);D) Button b = new Button( “關閉”);14. 在編寫異常處理的Java程序中,每個catch語句塊都應該與()語句塊對應,使得用

5、該語句塊來啟動 Java的異常處理機制。A) ifelse B) switch C) tryD) throw15. 在Java中,屬于整數(shù)類型變量的是()A) single B) double C) byte D) char16. Applet類的直接父類是()A) Component類B) Container 類 C) Frame 類D) Panel 類仃.Frame的默認的布局管理器是下列哪一個()A ) FlowLayout B) BorderLayout C) GridLayout D ) CardLayout18.在下列事件處理機制中哪個不是機制中的角色()A)事件 B)事件源 C)

6、事件接口D事件處理者佃.下列語句片段int a=10,b=4,c=20,d=6;System.out.println(a+*b+c*-d);的結果為()A ) 144D)不能執(zhí)行20. 下列語句片段:int a=-67,b=116,c=78;int d=a | b&c;B ) 281000011 011110011111001001100C) 14011101001001110System.out.println(d)的結果為()A) 70B) 6721. Java中訪問限定符不包括()A ) public B) privateC) 78D ) 56D) final22. 如果希望所有的控件在

7、界面上均勻排列,應使用下列那種布局管理器?A)BoxLayout B)GridLayout C)BorderLayout D)FlowLouLayout23.A )C)24.JAVA程序經常用到 遞歸” 讓別人反復調用自己” 自己反復調用自己”Which is Java keyword?A ) mathB ) staticC)C) default遞歸”的基本思想是()B)自己反復調用別人” D)以上說法都不對FALSE D ) TRUE25. What is the range of a char?3131A ) -32 768 32 767B ) -128 127 C) -2 2 -1D)

8、u0000 uFFFF26. Java變量中,以下不屬于復合類型的數(shù)據(jù)類型是()A)類B)字符型 C)數(shù)組型 D)接口27. 當方法遇到異常又不知如何處理時,下列哪種說法是正確的()A)捕獲異常B)拋出異常C)聲明異常D)嵌套異常28. 在Java中,不屬于整數(shù)類型變量的是()A ) doubleB) longC) intD) byte29. 在異常處理中,如釋放資源、關閉文件、關閉數(shù)據(jù)庫等由()來完成。A ) try 子句B ) catch子句 C) finally 子句D ) throw子句30. Which of the following are valid declarations?

9、A) char c= B) char c= cafeC) char c= 0xfgD) char c=xef31. Which of the following is true of anonymous innerclass?A) Anonymous inner class can be declared as private,protected or public.B) Anonymous inner class can implement multiple interfaces.C) if not extended or implemented, an anonymous innercla

10、ss can become immediate subclass of the outer class or implement an interface.D) if not extended or implemented, an anonymous inner class can become immediate subclass of outer class or implement mutiple interfaces.32. Which statement is true about an inner class?A) It must be anonymousB) It can t i

11、mplement an interfaceC) It is only accessible in the enclosing classD) It can access any final variables in any enclosing scope.33. Which is the main() method return of a application?A) String B) byte C) char D) void34. Which is corrected argument of main() method of application?A) String args B) St

12、ring args C) Char args D) StringBuffer args35. Given the following declarationString s = Example;Which are legal code?A ) s = 3;B) s3 = x;C) int i = s.length; D) String t =For + s;36. What is written to the standard output given the following statement: System.out.println(4&7);100Select the right an

13、swer: 111A ) 4 B ) 5C) 6 D) 737. What is written to the standard output given the following statement: System.out.println(7|9);Select the right answer:A ) 0 B ) 7C) 9 D) 1538. Consider the following code: Integer s = new Integer(9); Integer t = new Integer(9); Long u = new Long(9);Which test would r

14、eturn true?A) (s.equals(new Integer(9)B ) (s.equals(9)C) (s=u)D) (s=t)39. What should you use to position a Button within an application frame so that the width of the Button is affected by the Frame size but the height is not affected.A) FlowLayoutB)GridLayoutC) Center area of a BorderLayoutD) Nort

15、h or South of aBorderLayout40. If this source code is contained in a file called SmallProg.java, what command should be used to compile it using the JDK?public class SmallProg public static void main(String args) System.out.println(Good luck!); A) java SmallProgB)javac SmallProgC) java SmallProg.jav

16、aD) javacSmallProg.java41. Which statement about listener is true?A) Most component unallow 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 allow

17、s you to call an addXxxxListener method as many times as is needed, specifying as many different listeners as your design require.42. What will be the result when you run the following code?class Aclassvoid go()System.out.println(Aclass);public class Bclass extends Aclassvoid goSystem.out.println(Bc

18、lass);public static void main(String args)Aclass a=new Aclass();Aclass a1=new Bclass();a.go();a1.go();The output is:A ) AclassB ) BclassC) AclassD) BclassAclassBclassBclassAclass43. 已知有下列類的說明,則下列哪個語句是正確的?public class Test private float f = 1.0f;int m = 12;static int n=1;public static void main(Strin

19、g arg)Test t = new Test();A) t.f ;B) this.n ; C ) Test.m ; D) Test.f ;44. 給定下面的代碼片段:1) String str = null;2) if (str != null) & (strength() 10) 3) System.out.println(more than 10);4) 5) else if (str != null) & (str.length() 5) 6) System.out.println(less than 5);7) 8) else System.out.println(end); 哪一行

20、會導致錯誤?A)line 1B) line 2C)line 5D)line 845. 對于下列代碼:public class Parent public int addValue( int a, int b) int s;s = a+b; return s;class Child extends Parent 下述哪個方法可以加入Child類中實現(xiàn)多態(tài)?A) int addValue( int a, int b )/ do something.B) public void addValue (int a, int b )/ do something.C) public int addValue

21、( int a )/ do something.D) public int addValue( int a, int b ) /do something.46. 下列語句序列執(zhí)行后,k的值是()。int i=10, j=18, k=30;switch( j - i )case 8 : k+;case 9 : k+=2;case 10: k+=3;default : k/=j;A) 31B) 32C) 2D) 3347. Given the following class definition:class Aprotected int i;A(int i)this.i=i;which of th

22、e following would be a valid inner class for this class?A) class B B) class B extends A C) class B extends AD) class BB()System.out.println(“ i= ” + i); class A 48. Give the following java class:public class Examplestatic int x=new int15;public static void main(String args)System.out.println(x5);Whi

23、ch statement is corrected?A) When compile, some error will occur. B ) When run, some error will occur.C) Output is zero.D) Output is null.49. What will be the result of attempting to compile and run the following code? abstract class MineBaseabstract void amethod();static int i;public class Mine ext

24、ends MineBasepublic static void main(String args)int ar = new int5;for(i=0; iar.length; i+)System.out.println(ari);A ) a sequence of 5 0 s will be printedB ) Error: ar is used beforeit is initializedC) Error Mine must be declared abstract D ) IndexOutOfBoundes Error50. class Line public static class

25、 Point class Triangle II insert code hereWhich code, inserted at line 15, creates an instance of the Point class defined in Line?A. Point p = new Point();B. Line.Point p = new Line.Point();C. The Point class cannot be instatiated at line 15.D. Line 1 = new Line() ; 1.Point p = new 1.Point();二、寫出下列程序

26、完成的功能(每小題5分,共20分)1、public class Sumpublic static void main( String args )int sum = 0 ;for ( int i = 1 ; i = 100 ; i + + )sum += i ;System.out.println(“ sum= +sum );2、import java.io.* ;public class Reversepublic static void main(String args )int i , n =10 ;int a = new int10;for ( i = 0 ; i = 0 ; i-)S

27、ystem.out.print(ai+);System.out.println();3、import java.awt.*;public class AppOutpublic static void main(String args)new FrameOut();class FrameOut extends FrameLabel prompt;FrameOut()super(西南交通大學); prompt=new Label(西南交通大學歡迎您); setLayout(new FlowLayout(); add(prompt);setSize(300,200); show();4、import

28、 java.io.*;public class abcpublic static void main(String args) SubClass sb = new SubClass();System.out.println(sb.max();class SuperClass int a = 10 , b = 20 ; class SubClass extends SuperClass int max( ) return (ab)?a:b); 三、寫出下面程序的運行結果(每小題5分,共15分)1、import java.io.*;public class abcpublic static voi

29、d main(String args) String s1 = Hello!;String s2 = new String(I am fine!); System.out.println(s1+ +s2); 2、import java.io.* ;public class abcpublic static void main(String args) int i , s = 0 ;int a = 1,2,3,4,5,6,7,8,9,10 ;for ( i = 0 ; i a.length ; i + )if ( ai%2 = 0 ) s += ai; System.out.println(s=

30、+s);3、Give following programe:class EXpublic static void main(String args)outer: for(int i=0; i3; i+ ) inner: for(int j=0; j=1) break outer;System.out.println(j + and + i); What will be output?第二、三題參考答案:二、 寫出下列類完成的功能。(每小題5分,共20分 )1、求1至100之間的整數(shù)的和,并在屏幕上顯示岀來。2、從標準輸入(即鍵盤)讀入10個整數(shù)存入整型數(shù)組 a中,然后逆序輸岀這10個整數(shù)。3、

31、創(chuàng)建一個標題為“西南交通大學”的窗框,窗框中顯示有“西南交通大學歡迎您”字樣的標簽。4、求兩個數(shù)的最大值。三、寫出下面程序的運行結果 (每小題5分,共15分)1、Hello! I am fine!2、s=303、0 and 0When you are old and grey and full of sleep,And no ddi ng by the fire, take down this book,And slowly read, and dream of the soft lookYour eyes had once, and of their shadows deep;How many loved your mome nts of glad grace,And loved your beauty with love false or true,But one man loved the pilgrim soul in you.And loved the sorrows of your cha nging face;And bending dow n beside the glow ing bars,Murmur, a little sad

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論