




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、 JAVA考試試卷及答案選擇題3、在Java Applet程序用戶自定義的Applet子類中,一般需要重載父類的( D )方法來完成一些畫圖操作。 A. start() B. stop()C. init() D. paint()3、Java語言具有許多優點和特點,下列選項中,哪個反映了Java程序并行機制的特點?B A)安全性 B)多線程 C)跨平臺 D)可移植4、下列哪個類聲明是正確的?D A)abstract final class HI··· B)abstract private move()··· C)protected pr
2、ivate number; D)public abstract class Car···6、在Java語言中,下列哪些語句關于內存回收的說明是正確的 BA程序員必須創建一個線程來釋放內存; B內存回收程序負責釋放無用內存 C內存回收程序允許程序員直接釋放內存 D內存回收程序可以在指定的時間釋放內存對象 10、下列Object類中的方法,哪一項不是完全跟線程有關: AAString toString() Bvoid notify() Cvoid notifyAll() Dvoid wait()11、給出下面代碼:Cpublic class Person static
3、 int arr = new int10; public static void main(String a) System.out.println(arr1); 下列說法中正確的是 A編譯時將產生錯誤; B編譯時正確,運行時將產生錯誤; C 輸出零; D 輸出空。12、字符串是Java已定義的類型,關于它的構造函數,下面說法不正確的是: BAString(char value, int offset, int count) BString(int codePoints,int offset, int count) CString(String original)DString(StringB
4、uffer buffer)13、下列說法中正確的是: CA導入包會影響程序的性能B包存儲在類庫中C包是類的容器D上述說法都不對14、下列不是String類的常用方法是:CA、boolean equals(String str)B、int compareTo(String str)C、int SetindexOf(String str)D、int lastIndexOf(String str)17、表達式:(x>y) (z>w) x:z:w,(其中x=5,y=9,z=1,w=9)的值為:DA、5 B、8C、1 D、91、main方法是Java Application程序執行的入口點,
5、關于main方法的方法頭以下哪項是合法的( B )A、public static void main( )B、public static void main( String args )C、public static int main(String arg )D、public void main(String arg )5、欲構造ArrayList類的一個實例,下列哪個方法是正確的 BA ArrayList myList=new Object(); B ArrayList myList=new ArrayList(); C myList= new Object(); D myList= new
6、 ArrayList();7、哪個關鍵字可以對對象加互斥鎖 BAtransient Bsynchronized Cserialize Dstatic 9、下列敘述中,錯誤的是: DA、父類不能替代子類B、子類能夠替代父類C、子類繼承父類D、父類包含子類 10、下列關于Java多線程并發控制機制的敘述中,錯誤的是:BCA、Java中對共享數據操作的并發控制是采用加鎖技術B、線程之間的交互,提倡采用suspend()/resume()方法C、共享數據的訪問權限都必須定義為privateD、Java中沒有提供檢測與避免死鎖的專門機制,但應用程序員可以采用某些策略防止死鎖的發生12、下列哪一個方法不是
7、applet程序的組成部分:DA、init() B、start()C、stop() D、new()15、Java應用程序中,程序執行的總入口方法是:BA、start() B、main()C、run() D、init()16、在Java實現線程有多少種方法:BA、1 B、2C、3 D、418、下列Applet類的方法中,在Applet的整個生命周期里至多只執行一次的是:AA、init() B、start()C、stop() D、paint()19、啟動一個線程所調用的方法是:CA、run() B、init()C、start() D、new()判斷題1一個Java類可以有多個父類。4Java小程序
8、Applet的主類的父類必須是類Applet。5break語句可以用在循環和switch語句中。6在Java中,異常Exception是指程序在編譯和運行進出現的錯誤。7可以用new來創建一個類的實例,即對象。8Java使用16位的Unicode字符集,而不僅僅為ASCII字符集,因此Java字符是一個16位的無符號整數。10子類的成員變量能與其父類的成員變量同名。11Java類中不能存在同名的兩個成員函數。12Java語言是編譯性語言。16final方法不能被覆蓋。20多數I/O方法在遇到錯誤是會拋出異常,因此在調用這些方法時必須對異常進行處理。2abstract 是抽象修飾符,可以用來修飾
9、類及其屬性和方法。4一個Java Applet源程序的主類能有多個父類。6用javac編譯Java源文件后得到代碼叫字節碼。7可以用類名調用實例方法。9要想在類中實現多線程,類必須繼承Thread類。11Java語言是平臺無關的語言。12在類的靜態方法中可以訪問該類的非靜態數據成員。13Java中方法調用時參數傳遞都是按值傳遞的,因此從方法退出時,參數的值不會改變。14聲明為final的方法不能在子類中重載。15在子類中可以覆蓋一個private方法。19在方法定義中,所有可能發生的異常都必須用trycatch()捕捉并處理1.請寫出輸出結果class change void changein
10、t(int x) x+; public static void main(String args) int a=2; System.out.println("Before changed: "+"a="+a); /請系統輸出Before changed: a= change cxz=new change(); cxz.changeint(a); System.out.println("After changed: "+"a="+a); 答案:Before changed: a= 2 After changed: a
11、= 3 2. 下面程序運行的最終結果i是:_2_public class Foo public static void main (String args) int i = 1; int j = i+; if (i>+j) && (i+ =j) i +=j; 3、閱讀以下程序,請寫出輸出結果import java.lang.*;public class StrCompare public static void main(String args) String str1 = "Hello, Java!", str2 = "hello, jav
12、a!" System.out.println(pareToIgnoreCase(str2); System.out.println(str1.equals(str2); System.out.println(str1.equalsIgnoreCase(str2); 答:0FalseTrue4、閱讀以下程序,請寫出輸出第一行結果public class abc public static void main(String args ) int i =3,j ; while (i>0) j=3; while (j>0) if (j<2) break; System.ou
13、t.println("j+and"+i); j-; i-; 答:j+and3j+and3j+and2j+and2j+and1j+and15、 import java.io.*;public class abc public static void main(String args ) AB s = new AB("Hello!","I love JAVA."); System.out.println(s.toString( ); class AB String s1; String s2; AB( String str1 , Stri
14、ng str2 ) s1 = str1; s2 = str2; public String toString( ) return s1+s2;答:Hello!I love JAVA.6、閱讀以下程序,請寫出輸出c.x=是多少public class withstaticdata static int x; int y; public static void main(String args) withstaticdata a=new withstaticdata();a.x=1; System.out.println(a.x);withstaticdata b=new withstaticda
15、ta();b.x=2; System.out.println(b.x); System.out.println(a.x); withstaticdata c=new withstaticdata();System.out.println("c.x="+c.x); 答:2public class StaticFun static void incr() withstaticdata.x+;public static void main( String args ) StaticFun.incr(); 1、在橫線上填上適當的內容import java.awt.*;import
16、java.applet.*;public class AppletLife extends Applet /聲明為Apple類Color r; public AppletLife() /初始化 System.out.println("Applet initing.");r = Color.red;public void start()System.out.println("Applet starting.");public void stop()System.out.println("Applet stopping.");public
17、 void paint(Graphics g)System.out.println("Applet painting.");g.setColor(r);g.drawString("Painting here!", 50, 60 );public void destroy()System.out.println("Applet destroy.");2. 閱讀以下程序,請寫出輸出結果public class tt public static void main(String args) String s=new String("
18、;Bicycle");int iBegin=1;int iEnd=3;System.out.println(s.substring(iBegin,iEnd);答:ic3、請在相應的劃線上填上代碼public class CircumferenceTester public static void main(String args) Circle c1 = new Circle(); c1.radius = 50; Circle c2 = new Circle(); c2.radius = 10; double circum1 = c1.circumference(); double
19、circum2 = c2.circumference(); System.out.println("Circle 1 has circumference " + circum1); System.out.println("Circle 2 has circumference " + circum2); public class Circle private static double PI = 3.141; /靜態double 常量PI為 3.141 int radius; public double circumference() return 2*P
20、I*radius; public double area() return PI * radius * radius; public void enlarge(int factor) radius = radius * factor; public boolean fitsInside (Rectangle r) return (2 * radius < r.width) && (2 * radius < r.height); 4、閱讀以下程序,請寫出輸出結果class father void speak() System.out.println("I a
21、m father!"); public class son extends father void speak() super.speak(); System.out.println("I am son!"); public static void main(String args) son cxz=new son(); cxz.speak(); 答:I am father!I am son!5寫出下面程序的運行結果import java.io.*;class Parent void printMe() System.out.println("paren
22、t"); class Child extends Parent void printMe() System.out.println("child"); void printAll() super.printMe(); this.printMe(); printMe(); public class Class1 public static void main(String args ) Child myC = new Child( ); myC.printAll( ); 答:parentchildchild6寫出下面程序的運行結果 import java.io.*;
23、 public class abc public static void main(String args) String s1 = "Hello!" String s2 = new String("World!"); System.out.println(s1.concat(s2); 答:Hello!World!定義能計算圓的面積、周長的類circle,半徑r為私有數據分量,其值由類circle的構造函數初始化,類circle提供讀取半徑r的方法getr();計算面積的方法area();計算周長的方法circlelength()。再定義類circlec
24、omputer其包含程序運行所需的方法main,圓的半徑為1,請設計程序, 必須使用類circle的構造函數及方法初始化數據分量和計算圓的面積、周長并打印出如下形式的結果。半徑 面積 周長答:public class circle private int r;private static double PI = 3.141;public circle(int r) this.r = r;public int getR() return r;public double area() return PI * r * r;public double circlelength() return 2 *
25、 PI * r;public class circlecomputer public static void main(String args) circle c = new circle(1);/ 實例化circle并設置半徑為1System.out.println("半徑 面積 周長");System.out.print(c.getR();System.out.print(" ");System.out.print(c.area();System.out.print(" ");System.out.print(c.circlele
26、ngth();定義能計算三角形的面積、周長的類js,三邊a,b,c都為私有數據分量,其值由類sj的構造函數初始化,類js提供讀取各邊長度a,b,c的方法分別為geta(); getb(); getc(); 計算面積的方法area();計算周長的方法sjlength()。(三角形面積公式:c)-b)(s-a)(s-s(s 其中s=(a+b+c)/2)再定義類jxcomputer其包含程序運行所需的方法main,矩三角形的三邊a為3,b為6,c為8請設計程序必須使用類sj的構造函數及方法初始化數據分量和計算的三角形的面積、周長并打印出如下形式的結果。a b c 面積 周長答:public class js
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 【正版授權】 IEC 60335-2-118:2025 RLV EN Household and similar electrical appliances - Safety - Part 2-118: Particular requirements for professional ice-cream makers
- 2025年養老服務與社會保障基礎知識考試題目及答案
- 2025年心理健康教育與輔導考試試題及答案
- 2025年成人教育與培訓職業資格考試試題及答案
- 2025年城市規劃與設計專業考試題目及答案
- 2025年公共英語三級考試題及答案
- (三模)青島市2025年高三年級第三次適應性檢測語文試卷(含標準答案)
- 采購合同免責協議書范本
- 2025年煤及礦產品批發服務項目發展計劃
- 2025年中、高檔黑白超聲診斷儀項目建議書
- 2024年河南省機關單位工勤技能人員培訓考核高級工技師《職業道德》題庫
- DBJ15 31-2016建筑地基基礎設計規范(廣東省標準)
- 壓力容器制造質量保證手冊+程序文件+表格-符合TSG 07-2019特種設備質量保證管理體系
- 山東省濟南市歷城區2023-2024學年七年級下學期期末語文試題(解析版)
- DL∕T 1864-2018 獨立型微電網監控系統技術規范
- 2024年湖南省中考道德與法治試題卷(含答案解析)
- 極坐標法課件講解
- 蘇州2024年江蘇蘇州張家港市事業單位招聘筆試筆試歷年典型考題及考點附答案解析
- 八年級語文下冊(部編版) 第四單元 經典演講-單元主題閱讀訓練(含解析)
- 2024新高考英語1卷試題及答案(含聽力原文)
- (高清版)JTGT 3654-2022 公路裝配式混凝土橋梁施工技術規范
評論
0/150
提交評論