1
o
B.
2
o
C.
3
o
D.
4
正确答案:A
? 33.
(单选)下面的代码用于对数组arr实现冒泡排序: for (int i = 0; i < arr.length - 1; i++) { boolean isSwap = false; 空白处 if (!isSwap) break; } 下列选项中,空白处可以填入的代码是:()。
o
A.
for (int j = arr.length - 1; j > i; j--) { if (arr[j] < arr[j - 1]) { int temp = arr[j]; arr[j] = arr[j - 1]; arr[j - 1] = temp; isSwap = true; } }
o
B.
for (int j = arr.length - 1; j > 0; j--) { if (arr[j] < arr[j - 1]) { int temp = arr[j]; arr[j] = arr[j - 1]; arr[j - 1] = temp; isSwap = true; } }
o
C.
for (int j = i + 1; j< arr.length; j++) { if (arr[j] < arr[j - 1]) { int temp = arr[j]; arr[j] = arr[j - 1]; arr[j - 1] = temp; isSwap = true; } }
o
D.
for (int j = i; j< arr.length; j++) { if (arr[j] < arr[j - 1]) { int temp = arr[j]; arr[j] = arr[j - 1]; arr[j - 1] = temp; isSwap = true; } }
正确答案:C
? 34.
(单选)请看下列代码: class Payload { private int weight; public Payload(int wt) { weight = wt; } public Payload() {} public void setWeight(int w) { weight = w; } public String toString() { return Integer.toString(weight); } } public class TestPayload { static void changePayload(Payload p) { <插入代码> } public static void main(String[] args) { Payload p = new Payload(); p.setWeight(1024); changePayload(p); System.out.println(\假设运行后输出“The value of p is 420”,那么<插入代码>处应填入代码是:
o
A.
p.setWeight(420);
o
B.
Payload.setWeight(420);
o
C.
p = new Payload(420);
o
D.
p = new Payload(); p.setWeight(420);
正确答案:D
? 35.
(单选)下列代码运行的结果是()。 public class Base { public static final String FOO = \public static void main(String[] args) { Base b = new Base(); Sub s = new Sub(); System.out.print(Base.FOO); System.out.print(Sub.FOO); System.out.print(b.FOO);
System.out.print(s.FOO); System.out.print(((Base) s).FOO); } } class Sub extends Base { public static final String FOO = \
o
A.
foofoofoofoofoo
o
B.
foobarfoobarbar
o C.
foobarfoofoofoo
o
D.
foobarfoobarfoo
正确答案:C
? 36.
(多选)请看下列代码: public abstract class Shape { int x; int y; public abstract void draw(); public void setAnchor(int x, int y) { this.x = x; this.y = y; } } 下列选项中能正确使用Shape类的是:
o
A.
public class Circle implements Shape { private int radius; }
o
B.
public abstract class Circle extends Shape { private int radius; }
o
C.
public class Circle extends Shape { private int radius; public void draw(); }
o
D.
public class Circle extends Shape { private int radius; public void draw() {/* code here */} }
正确答案:BCD
? 37.
(多选)在Java语言中,下列说法正确的是()。
o
A.
一个接口可以继承多个接口
o
B.
一个类可以继承多个类
o
C.
一个类可以实现多个接口
o
D.
一个类可以有多个子类
正确答案:ACD
? 38.
(多选)请看下列代码: package com.tarena; public class Geodetics { public static final double DIAMETER = 12756.32; } 访问静态常量DIAMETER的方式正确的是:
o
A.
import com.tarena.Geodetics; public class TerraCarta { public double halfway(){ return Geodetics.DIAMETER/2.0; } }
o
B.
import com.tarena.Geodetics; public class TerraCarta { public double halfway(){ return DIAMETER/2.0; } }
o
C.
import com.tarena; public class TerraCarta { public double halfway(){ return Geodetics.DIAMETER/2.0; } }
o
D.
import com.tarena.*; public class TerraCarta { public double halfway(){ return Geodetics.DIAMETER/2.0; } }
正确答案:AD
? 39.
(多选)请看下列代码 public class Foo { public void method(String str,int age){} } 和Foo类中method方法重载的方法是:
o
A.
public int method(String str,int age){}
o
B.
public void method(String s,int year){}
o
C.
public void method(int year,String s){}
o
D.
public int method(int year,String s){}
正确答案:ACD
? 40.
(多选)在<插入代码>处,填入下列代码编译正确的是: public void foo(int[] x) { <插入代码> }
o
A.
foreach(int z : x) System.out.println(z);
o
B.
for(int z : x) System.out.println(z);
o
C.
while( x.hasNext()) System.out.println( x.next());
o
D.
for( int i=0; i< x.length; i++ ) System.out.println(x[i]);
正确答案:BD
? 41.
(多选)查看如下代码: class A { protected int method (int a, int b) { return 0; } } 下列选项中,可以在 A 的子类中使用的是()。
o
A.
public int method (int a, int b) { return 0; }
o
B.
private int method(int a, int b) { return 0; }
o
C.
private int method(int a, long b) { return 0; }
o
D.
public short method(int a, int b) { return 0; }
正确答案:AC
? 42.
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库达内java2015.11第一次月考(附答案).doc(4)在线全文阅读。
相关推荐: