




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
1、1) 2) 3) 4) 5) 6) 7) 8) 9) 10) 11) 12) 1. 2. 3. 4. 5. 6. 7. 8. 9. 填空題 數(shù)組的元素通過下標(biāo) 來訪問,數(shù)組 Array的長度為Arrav.length 數(shù)組復(fù)制時,=將一個數(shù)組的引用傳遞給另一個數(shù)組。 JVM將數(shù)組存儲在 棧 (堆或棧)中。 數(shù)組的二分查找法運用的前提條件是數(shù)組已經(jīng)排序 。 Java中數(shù)組的下標(biāo)的數(shù)據(jù)類型是 整型。 數(shù)組最小的下標(biāo)是0。 arraycopy()的最后一個參數(shù)指明復(fù)制元素的個數(shù)。 向方法傳遞數(shù)組參數(shù)時,傳遞的是數(shù)組的引用 。 數(shù)組初始化包括數(shù)組的申明,創(chuàng)建和初始化 。 數(shù)組下標(biāo)訪問超出索引范圍時拋出
2、 數(shù)組越界異常 浮點型數(shù)組的默認(rèn)值是O.Of 。 數(shù)組創(chuàng)建后其大小不能 改變。 選擇題 下面錯誤的初始化語句是_ABD_ A. char str=hello;B. char str100=hello; C. char str=h,e,T,T,o;D. char str=hello; 定義了一維int型數(shù)組a10后,下面錯誤的引用是 _B_ A. a0=1; B. a10=2;C. a0=5*2;D. a1=a2*a0; 下面的二維數(shù)組初始化語句中,正確的是 A. float b22=0.1,0.2,0.3,0.4; C. int a2= 1,2,3,4; 引用數(shù)組元素時,數(shù)組下標(biāo)可以是 A.
3、整型常量B.整型變量 B. i nt a=1,2,3,4; D. float a22=0; D_ C. 整型表達式D.以上均可 11 / 10 定義了 int型二維數(shù)組a67后,數(shù)組元素a34前的數(shù)組元素個數(shù)為 A. 24B. 25C. 18D. 17 F列初始化字符數(shù)組的語句中,正確的是_B. B. char str=h,e,T,T,o,0; D. char str100=; C. 堆D.鏈表 A. char str5=hello; C. char str5=hi; 數(shù)組在Java中儲存在 C 中 A.棧B.隊列 下面程序的運行結(jié)果是 mai n() int a=1,2,3,4,5,6; S
4、ystem.out.pri ntf(%d, a11); A. 3 B. 4 C. 5 D. 6 F面程序的運行結(jié)果是_C. mai n() int x=30; int numbers=new intx; x=60; System.out.println(numbers.length); A. 60 B. 20 C. 30 D. 50 下面程序的運行結(jié)果是 _BDF_ main() char s1=ABCDEF.toCharArray(); int i=0; 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. while(s1i+!=0) System.out.pri
5、ntln(s1i+); A. ABCDEF B. BDF C. ABCDE 下面 不是創(chuàng)建數(shù)組的正確語句 C A.float f=new float66; C.float f=new float6; 下面不是數(shù)組復(fù)制方法的是 (C) A. 用循環(huán)語句逐個復(fù)制數(shù)組 C. 用 =進行復(fù)制 數(shù)組 a 的第三個元素表示為 D A. a(3)B. a3 當(dāng)訪問無效的數(shù)組下標(biāo)時,會發(fā)生 B A. 中止程序B. 拋出異常 D. BCDE B. float f=new float6; D.float f=new float6; B. 用方法 arraycopy D. 用 clone 方法 C. a(2)D.
6、a2 C. 系統(tǒng)崩潰D. 直接跳過 使用 arraycopy() 方法將數(shù)組 a 復(fù)制到 b 正確的是 A A. arraycopy(a,0,b,0,a.length) B. arraycopy(a,0,b,0,b.length) C. . arraycopy(b,0,a,0,a.length) 關(guān)于數(shù)組默認(rèn)值,錯誤的是 B D. arraycopy(a,1,b,1,a.length) A. char-u0000B. Boolean-trueC. float-0.0fD. int- 0 關(guān)于數(shù)組作為方法的參數(shù)時,向方法傳遞的是 A A. 數(shù)組的引用 B. 數(shù)組的棧地址 C. 數(shù)組自身 D. 數(shù)
7、組的元素 關(guān)于數(shù)組復(fù)制,下列說法錯誤的是 AC A. = 可以實現(xiàn)數(shù)組復(fù)制 B. 運用循環(huán)語句進行數(shù)組復(fù)制必須兩個數(shù)組長度相同 C. arraycopy()方法沒有給目標(biāo)數(shù)組分配內(nèi)存空間 D. 數(shù)組復(fù)制是數(shù)組引用的傳遞 下列語句會造成數(shù)組 new int10 越界是 D A. a0 += 9; B. a9=10;C. a9D. for(int i=0;i=10;i+) ai+; 20.在JDK環(huán)境下編譯JAVA源程序使用的命令是(B ) A.javaB.javac C.jvm D. 子類不能使用父類的構(gòu)造方法 D.tomcat 21. main 方法是 java Application 程序執(zhí)
8、行的入口點。 關(guān)于 main 方法放入方法以下合法的是 A. public static void main(); B. public static void main(Stringargs) 22. 23. C. public static int main(String arg) D. public void main(String arg) 執(zhí)行完代碼 int x=new int25; 后以下 ( A )說明正確的 A. x24為 0B. x24未定義C. x25為 0 關(guān)于數(shù)組排序方法,錯誤的是 C A. 選擇排序B. 插入排序 C. 二分排序 D. x0為空 D. 用 arrays.
9、sort( )排序 24. 關(guān)于 char 類型的數(shù)組,說法正確的是 A. 其數(shù)組的默認(rèn)值是 A C. 數(shù)組不能轉(zhuǎn)換為字符串 B. 可以僅通過數(shù)組名來訪問數(shù)組 D. 可以存儲整型數(shù)值 25. 對于數(shù)組 a10 ,下列表示錯誤的是 A. a0B. a(0) 26. 下列數(shù)組聲明,下列表示錯誤的是 C. a9 D. a1 A. int a 三、是非題 B. int a C. int a D. inta 1.下標(biāo)用于指出數(shù)組中某個元素位置的數(shù)字。 ( 2. 把數(shù)組中元素按某種順序排列的過程叫做查找。 3. 確定數(shù)組中是否含有某個關(guān)鍵字的過程叫做排序。 4. 一個數(shù)組可以存放許多不同類型的數(shù)值。 5.
10、 數(shù)組的下標(biāo)通常是float 型。 () 6. 數(shù)組的某個元素被傳遞給一個方法并被該方法修改, 中含有修改過的數(shù)值。 () 當(dāng)被調(diào)用方法執(zhí)行完畢時,這個元素 7. 數(shù)組可以聲明為任何數(shù)據(jù)類型。() 8. 數(shù)組由具有一名字和相同類型的一組連續(xù)內(nèi)存單元構(gòu)成。() 9. 在數(shù)組聲明中可以用等號及一個逗號分隔的初始值表初始化數(shù)組元素, 用戶來決定。 () 該數(shù)組大小只能由 10. 將一個數(shù)組傳遞給一個方法,必須加在數(shù)組名后加方括號。 () 11. Java語言中的數(shù)組元素下標(biāo)總是從0開始,下標(biāo)可以是整數(shù)或整型表達式。() 12. 下面這條語句正確嗎? () double myList; myList
11、= 1.9, 2.9, 3.5, 4.6; 14. 數(shù)組中有l(wèi)ength()這個方法,如 array.length()表示數(shù)組array中元素的個數(shù)() 15. 下面這條語句正確嗎 ?() int t32 = 1,2,3,4,5,6; 16. 數(shù)組聲明后其大小固定。 ( ) 17. 設(shè)有整型數(shù)組的定義: int A.=new int8; ,則 a.length 的值為 7。 ( ) 18. 數(shù)組一旦創(chuàng)建,其大小不能再改變。 ( ) 19. 用任何方式創(chuàng)建數(shù)組時,都必須指定數(shù)組的長度。 ( ) 20. 聲明數(shù)組時,要指定數(shù)組長度,以便為數(shù)組分配內(nèi)存。 ( ) 四、簡答題 1. 如何聲明和創(chuàng)建一個
12、一維數(shù)組? 2. 如何訪問數(shù)組的元素? a 的第三個元素如何表示? 3. 數(shù)組下標(biāo)的類型是什么?最小的下標(biāo)是什么?一維數(shù)組 4. 數(shù)組越界訪問會發(fā)生什么錯誤?怎樣避免該錯誤? 5. 給方法傳遞數(shù)組參數(shù)與傳遞基本數(shù)據(jù)類型變量的值有何不同? 6. 復(fù)制數(shù)組有哪些方法? 8.聲明數(shù)組變量會為數(shù)組分配內(nèi)存空間嗎?為什么? 五、程序題 1. 有一個整數(shù)數(shù)組,其中存放著序列1,3,5,7,9,11, 13,15,17,19。請將該序列倒 序存放并輸出。 1) public class Test 2) public static void main(String args) 3) int a = 1,3,5
13、,7,9,11,13,15,17,19; 4) int t; 5) System.out.println(”數(shù)組的初始狀態(tài)為:); 6) for (int i=0; i a.length; i+) 7) System.out.print( + ai); 8) System.out.println(); 9) 9) for (int i=0; i a.length/2; i+) 10) t = ai; 11) ai = aa.length-i-1; 12) aa.length-i-1=t; 13) 15) 14) System.out.println(數(shù)組逆序存放后的狀態(tài)為:); 15) for
14、 (int i=0; i a.length; i+) 16) System.out.print( + ai); 17) 18) 2. 編寫一個程序,提示用戶輸入學(xué)生數(shù)量姓名和他們的成績,并按照成績的降序來打印學(xué) 生的姓名。 1) public class exercise16 2) public static void main(String args) 3) String numberString = 4) JOptionPane.showInputDialog(Enter the number of students); 5) int numberOfStudents = Integer.
15、parseInt(numberString); 6) 7) String names = new StringnumberOfStudents; 8) double scores = new doublenumberOfStudents; 9) 10) for (int i = 0; i = 1; i-) 17) double currentMax = scores0; 18) int currentMaxIndex = 0; 19) 20) for (int j = 1; j = i; j+) 21) if (currentMax = 0; i-) 37) System.out.printl
16、n(namesi + t + scoresi); 38) 39) 40) 3. 編寫一個程序,使它能夠讀入 10 個整數(shù),并且存儲其中互不相同的數(shù),最后將這10 個數(shù) 輸出。 1) import javax.swing.JOptionPane; 2) 3) public class exercise5 4) 5) 6) 7) 8) 9) 10) 11) 12) 13) 14) 15) 16) 17) 18) 19) 20) 21) 22) 23) 24) 25) 26) 27) 28) 29) 30) 31) 32) 33) 34) 35) 36) 37) 38) 39) 40) 41) 42
17、) 43) 44) 45) private static int j = 0; public static void main(String args) int arrayInt = new int10; int i = 0; do String numberString = JOptionPane .showInputDialog(Enter a number: ); int number = Integer.parseInt(numberString); if (isNotHave(arrayInt, number) arrayInti = number; i+; j+; else do
18、numberString = JOptionPane .showInputDialog(This number is exit,enter a another number: ); number = Integer.parseInt(numberString); while (!isNotHave(arrayInt, number); arrayInti = number; i+; j+; while (i arrayInt.length); String output = ; for (int k : arrayInt) output += k + ; JOptionPane.showMes
19、sageDialog(null, The elements of arrayInt is + output, output arrayInt, JOptionPane.INFORMATION_MESSAGE); public static boolean isNotHave(int arrayInt, int n) for (int i = 0; i j; i+) 46) if (arrayInti = n) 47) return false; 48) 49) return true; 50) 51) 4.先對數(shù)組 1,3, 9,5,6,7,1,5,4,8進行排序,然后二分查找法找出數(shù)組中的元
20、素 8,標(biāo)出其排序后其下標(biāo)的位置。 1) public class Test 2) public static void main(String args) 3) int numbers = 1,3,9,5,6,7,1,5,4,8; 4) java.util.Arrays.sort(numbers); 5) 6) System.out.println(”排序后的數(shù)組為:); 7) for (int i=0; i low) mid = (mid = (low + high) / 2) ? 22) (mid + 1) : (low + high) / 2) 23) if (key = 0); 15
21、) 16) double average = (sum - scorescount) / (count - 1); 17) 18)int numOfAbove = 0; 19) int numOfBelow = 0; 20) for (int i = 0; i = average) 22) numOfAbove+; 23) else 24) numOfBelow+; 25) 26) System.out.println(Average is + average); 27) System.out.println(Number of scores above or equal to the ave
22、rage 28) + numOfAbove); 29) System.out.println(Number of scores below the average 30) + numOfBelow); 31) 32) System.exit(0); 33) 34) 6. 編寫一個程序,生成 0-9 之間的 100 個隨機整數(shù)并且顯示每一個數(shù)的個數(shù)。 1) public class exercise7 2) public static void main(String args) 3) int numbers = new int100; 4) int counts = new int10; 5)
23、 6) int k; 7) for (int i = 0; i 100; i+) 8) 9) numbersi = (int)(Math.random() * 10); 10) countsnumbersi+; 11) 12) 13)System.out.println(the 100 numbers is :); 14) 15) 16) 17) 18) 19) 20) 21) 22) 23) for(int i = 1; i = numbers.length; i+) if (i % 10 != 0) System.out.print(numbersi-1 + ); else System.
24、out.println(numbersi-1); System.out.println(the counts of each number is :); for(int i = 1; i = counts.length; i+) 24) System.out.print(countsi-1 + ); 25) 26) 7. 求平均值和方差。利用 mean(int numbers) 求平均值,利用 deviation(int numbers) 求標(biāo) 準(zhǔn)差。 1) import java.util.Scanner; 2) public class MeanDeviation 3) public st
25、atic void main(String args) 4) Scanner in = new Scanner(System.in); 5) 6) System.out.print(輸入數(shù)組的長度:); 7) int n = in.nextInt(); 8) 8) System.out.print(輸入數(shù)組元素:); 9) int array = new intn; 10) for (int i = 0; i array.length; i+) 11) 12) arrayi = in.nextInt(); 13) 15) 16) System.out.print(The mean is: + mean(array) + n 17) + The deviation is: + deviation(a
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 生物化學(xué)(第4版)課件 第7章 脂質(zhì)代謝
- 超高性能混凝土框架節(jié)點抗震性能研究
- 兒童健康檢查培訓(xùn)
- 盧桑斯的權(quán)變管理理論
- 黃疸的問診要點與護理診斷
- 頸部疾病病人護理課件
- 我的健康早餐分享
- 幼兒春游欣賞活動方案設(shè)計
- 健康素養(yǎng)大講堂
- 預(yù)防網(wǎng)絡(luò)詐騙班會課件
- 歷史人教部編版八年級(上冊)第13課五四運動課件(23張)2024版新教材
- 美國技術(shù)服務(wù)合同英文翻譯
- 企業(yè)數(shù)字化生存指南
- 醫(yī)院醫(yī)療器械臨床試驗項目資料備案清單
- YDT 5206-2023寬帶光纖接入工程技術(shù)規(guī)范
- 新疆警察學(xué)院面試問題及答案
- 小學(xué)三到六年級全冊單詞默寫(素材)-2023-2024學(xué)年譯林版(三起)小學(xué)英語
- 鐵嶺市高校畢業(yè)生“三支一扶”計劃招募筆試真題2022
- 天然氣泄漏事故演練方案及評估
- 《養(yǎng)老機構(gòu)認(rèn)知障礙照護專區(qū)設(shè)置與服務(wù)規(guī)范》
- 婦科炎癥健康教育課件
評論
0/150
提交評論