




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
本文格式為Word版,下載可任意編輯——Java輸入輸出(含部分答案)Java輸入輸出
知識點:
1、文件和流的操作,理解字節(jié)流和字符流的概念2、異常處理的概念,自定義異常類
一、選擇題
1、假使一個程序段中有多個catch,則程序會按如下哪種狀況執(zhí)行?()
A)找到適合的例外類型后繼續(xù)執(zhí)行后面的catchB)找到每個符合條件的catch都執(zhí)行一次
C)找到適合的例外類型后就不再執(zhí)行后面的catchD)對每個catch都執(zhí)行一次
2、程序員將可能發(fā)生異常的代碼放在()塊中,后面緊跟著一個或多個()塊。
A)catch、tryB)try、catch
C)try、exceptionD)exception、try
3、在Java語言中,在程序運行時會自動檢查數(shù)組的下標是否越界,假使越界,會拋擲下面的異常()
A)SQLExceptionB)IOExceptionC)ArrayIndexOutOfBoundsExcetionD)SecurityManager
4、在Java中,關(guān)于捕獲異常的語法try-catch-finally的以下描述哪些正確?()A)try-catch必需配對使用B)try可以單獨使用
C)try-finally必需配對使用D)在try-catch后假使定義了finally,則finally確定會執(zhí)行
5、給定下面的代碼片斷:
publicclassAnimal{publicvoidCat(){try{
Method();}
catch(ArrayIndexOutBoundsExceptione){System.out.println(\catch(Exceptione)
{System.out.println(\finally
{System.out.println(\}
publicvoidMethod(){//...}
publicstaticvoidmain(String[]args){
Animal.Ani=newAnimal();Ani.Cat();}}
假使函數(shù)method正常運行并返回,會顯示下面的哪些信息?()A)HelloWorldB)Exception1
1
C)Exception2D)HelloWorld!!
6、假使以下的方法能夠正常運行,在控制臺上將顯示什么?()
publicvoidexample(){try{
unsafe();
System.out.println(\}
catch(SafeExceptione){System.out.println(\}
finally{System.out.println(\System.out.println(\}
A)Test1B)Test2C)Test3D)Test4
7、以下哪一項不是File類的功能:()
A)創(chuàng)立文件B)創(chuàng)立目錄C)刪除文件D)拷貝文件
2、下面哪個不是InputStream類中的方法:()A)intread(byte[])B)voidflush()C)voidclose()D)intavailable()8、構(gòu)造BufferedInputStream的適合參數(shù)是哪個?
A)BufferedInputStreamB)BufferedOutputStreamC)FileInputStreamD)FileOuterStreamE)File9、要從文件\file.dat\文件中讀出第10個字節(jié)到變量C中,以下哪個方法適合?()
A)FileInputStreamin=newFileInputStream(\c=in.read();
B)FileInputStreamin=newFileInputStream(\c=in.read();
C)FileInputStreamin=newFileInputStream(\D)RandomAccessFilein=newRandomAccessFile(\
intc=in.readByte();
10、以下程序發(fā)生什么異常?classA{intx;
publicstaticvoidmain{Ax;
System.out.println(x.x);}}
A.IOException
B.InterruptExceptionC.NullPointerExceptionD.DataFormatException11、設有如下方法:publicvoidtest(){try{
2
oneMethod();
System.out.println(\
}catch(ArrayIndexOutOfBoundsExceptione){System.out.println(\}catch(Exceptione){
System.out.println(\}finally{
System.out.println(\}}
假使oneMethod正常運行,則輸出結(jié)果中有哪些?A.condition1B.condition2C.condition3D.finally
12、設有如下代碼:publicvoidfun(){inti;try{
i=System.in.read();
System.out.println(\}catch(IOExceptione){
System.out.println(\}finally{
System.out.println(\}
System.out.println(\}
假使有一個IOException發(fā)生,則輸出有哪些?A.Location1B.Location2C.Location3D.Location4
13、設有如下代碼:
1Strings=null;
2if(s!=nullreturn;
}catch(IOExceptionx1){
System.out.println(\return;
}catch(Exceptionx2){
System.out.println(\return;}finally{
System.out.println(\}
假使tryThis()拋出NumberFormatException,則輸出結(jié)果是?A.無輸出
B.\后跟\C.\后跟\D.\E.\
16、以下哪個是RandomAccessFile文件的構(gòu)造方法:A.RandomAccessFile(\B.RandomAccessFile(\C.RandomAccessFile(\D.RandomAccessFile(\17、設有如下代碼:importjava.io.*;publicclassTh{
publicstaticvoidmain(Stringargv[]){Tht=newTh();t.amethod();}
publicvoidamethod(){try{
ioCall();
}catch(IOExceptionioe){}}
4
}
以下哪個最有可能是ioCall方法的方法體?
A.publicvoidioCall()throwsIOException{
DataInputStreamdin=newDataInputStream(System.in);din.readChar();}
B.publicvoidioCall()throwIOException{
DataInputStreamdin=newDataInputStream(System.in);din.readChar();}
C.publicvoidioCall(){
DataInputStreamdin=newDataInputStream(System.in);din.readChar();}
D.publicvoidioCallthrowsIOException(){
DataInputStreamdin=newDataInputStream(System.in);din.readChar();}
18、當前目錄不存在名為Hello.txt的文件,執(zhí)行下面代碼的輸出結(jié)果為?importjava.io.*;publicclassMine{
publicstaticvoidmain(Stringargv[]){Minem=newMine();
System.out.println(m.amethod());}
publicintamethod(){try{
FileInputStreamfile=newFileInputStream(\}
catch(FileNotFoundExceptione){
System.out.print(\return-1;}
catch(IOExceptione){
System.out.print(\}
return0;}}
A.NosuchfilefoundB.Nosu
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 銀監(jiān)會融資融券管理辦法
- 銀行柜員制管理暫行辦法
- 銷售合伙人財務管理辦法
- 項目管理部印章管理辦法
- 項目部疫情封閉管理辦法
- 中藥藥理學復習題集與答案
- 2025中化集團招聘星耀生·客戶關(guān)系類筆試歷年參考題庫附帶答案詳解
- 2025河南省鶴壁恒源礦業(yè)集團有限公司招聘18名工作人員筆試歷年參考題庫附帶答案詳解
- 2025漢江集團公司安置中心面向集團內(nèi)部招聘情況及考試安排(湖北)筆試歷年參考題庫附帶答案詳解
- 2025浙江杭州蕭山寧圍街道資產(chǎn)經(jīng)營公司公開招聘3人筆試歷年參考題庫附帶答案詳解
- 2026年中考英語復習:338條核心短語背誦卡+默寫卡
- 2025年天津市中考物理真題 (解析版)
- GA/T 2182-2024信息安全技術(shù)關(guān)鍵信息基礎設施安全測評要求
- 2025年北京市中考物理試題(解析版)
- 培訓物業(yè)客服部禮儀禮節(jié)
- 2025住建發(fā)布《房屋市政工程安全員開展崗前巡查指導手冊》
- 2025-2030中國新能源汽車充電樁行業(yè)供需狀況及投資戰(zhàn)略規(guī)劃分析報告
- 腫瘤患者血象解讀與臨床意義
- 關(guān)于員工廉潔培訓課件
- 院感知識手衛(wèi)生培訓內(nèi)容
- 2025年福建省中考語文試卷真題(含標準答案)
評論
0/150
提交評論