【正文】
int s = 0, i = 1。10) } catch(ArrayIndexOutOfBoundsException e1) {11) (caught + e + in AAA)。第8章 例外處理一、選擇題 下面兩個(gè)類分別定義在不同的源文件中:1) public class Test1 {2) public void method() throws IOException{}3) }1) public class Test2 extends Test1{2) … 3) }請(qǐng)問(wèn)下面哪些方法可以分別放置在類Test2的第2行處?其中Axn和Bxn都是都是IOException類的子類。8) }9) }10) }運(yùn)行程序時(shí)的輸出結(jié)果如下:11109為實(shí)現(xiàn)上述輸出結(jié)果,下面哪行代碼應(yīng)該插入在第6行處?A) i[a] = (x[a])。4) int i[] = new int[3]。}public int getCount(int n){ return count[n]。 }}A) 編譯出錯(cuò):數(shù)組類型無(wú)效B) 編譯出錯(cuò):數(shù)組元素count[0]沒(méi)有被初始化C) 先輸出null,然后引發(fā)ArrayIndexOutOfBoundsExceptio例外D) 先輸出一個(gè)表示數(shù)組對(duì)象的字符串,然后輸出0 給定下面類定義:public class Demo{private int[] count??紤]以下語(yǔ)句:int[] x = new int[11]。\39。6) }假定該應(yīng)用程序有下面代碼片段:7) String theFile = 。)。D) Integer j = new Integer(27)。B) String a = abcdefg。2) String s2 = AB + C123。String s2 = s1。18) }19) }20) class Test {21) public static void main(String[] args) {22) Xxx x = new Xxx(100)。10) x = new Xxx()。 3) Xxx x。 ()。 }}class TypeAWidget extends BaseWidget{ TypeAWidget() { name = TypeA。 編譯、運(yùn)行下面代碼將發(fā)生什么?class Base {}class Sub extends Base {}public class Cex { public static void main(String argv[]) { Base b = new Base()。 }}A) super(100)。 }}class B extends A { public static void main(String[] args) { B b = new B(2)。D) 兩個(gè)類都能被編譯,并且當(dāng)調(diào)用方法method()時(shí),將輸出3。 }}選擇一個(gè)正確的答案。 rg = null。5) (prmth2 = + mth2)。 (The x value is + x)。}}A) 從不輸出 B) 每次創(chuàng)建實(shí)例時(shí)輸出C) 當(dāng)類被裝入Java虛擬機(jī)時(shí)輸出 D) 當(dāng)static方法被調(diào)用時(shí)輸出 下面應(yīng)用程序的運(yùn)行結(jié)果是什么?public class MyTest { int x = 30。}public static void main(String args []) {StaticTest st1 = new StaticTest()。 } public static void print() { (Test)。 else (b)。Boolean b2 = new Boolean(true)。B) main方法的參數(shù)聲明不合法。 編譯下面代碼將會(huì)發(fā)生什么錯(cuò)誤?public class MyClass { public static void main(String arguments[]) { amethod(arguments)。 }}A) 代碼被編譯,運(yùn)行時(shí)輸出0。 if (i 1) continue one。 i 3。 F) 數(shù)字4會(huì)被輸出。 B) 代碼不能被編譯。}A) one B) one, defaultC) one, two, default D) default 關(guān)于下面代碼的陳述,哪些是正確的?void looper() { int x = 0。 break。 else (j)。}A) true B) false C) 出錯(cuò) D) 沒(méi)有信息輸出 寫(xiě)出下面代碼段的運(yùn)行結(jié)果(單選)int i = 3。 (s)。 }}A) 輸出:x=128 y=128 B) 輸出:x=128 y=129C) 輸出:x=128 y=128 D) 輸出:x=128 y=127 如果調(diào)用下面方法且參數(shù)值為67,那么方法的返回值是多少?public int MaskOff(int N){ return N^3。 int y = a + 1。 }}class TestExcise0203 { public static void main(String args[]) { Excise0203 o = new Excise0203()。\uffff39。G) char C=4096。 C) byte b = 257。 D) 輸出“The end”。/* This is another ment */ (The end)。附件3: 《面向?qū)ο蟪绦蛟O(shè)計(jì)》習(xí)題第1章 Java程序初步一、簡(jiǎn)答題 什么叫對(duì)象?什么叫類?類和對(duì)象有什么關(guān)系。 }}請(qǐng)問(wèn)下面哪條命令能夠運(yùn)行上面程序并輸出“The word is gamma”?A) Demo beta gamma delta B) java Demo gamma beta deltaC) java demo beta gamma delta D) java Demo beta gamma deltaE) java gamma beta delta 編譯、運(yùn)行下面代碼將發(fā)生什么?public class Test5 {public static void main (String args []) {/* This is the start of a ment(Done the test)。C) 輸出“Done the test”。 B) double D=。 F) char c = a。 char a1=39。 (b= + b + b1= + b1)。 int x = ++a。 ()。 String s = a ==