达内jsd1510第一次月考题,java第一阶段面向对象语法基础考试试题 下载本文

B.String st2 = \String(\

C.Integer i = 100; System.out.println(100 == i); D.ArrayList list = new ArrayList(); System.out.println(list.contains(null)); 正确答案:D 30.

(单选)请看下列代码,出现错误的行是:() public interface Cookie{ Cookie cookie=new Cart (\小面包\盼盼\Cart implements Cookie{ private String name; private String production; public Cart(String name,String

production){ this.name=name; this.production=production; } public void smell(){ cookie =new Cart(\蛋黄派\达利园\ A.第2行 B.第4行 C.第11行 D.第12行 正确答案:D 31.

(单选)请看下列代码的输出结果是: public class Bootchy { int bootch; String snootch; public Bootchy() { this(\

System.out.print(\

\bootch, String snootch) { this.bootch = bootch; this.snootch = snootch; System.out.print(\args) { Bootchy b = new Bootchy(); System.out.print(b.snootch + \+ b.bootch); } }

A.first second third snootchy 420 B.third second first snootchy 420 C.third first second snootchy 420 D.first second first third snootchy 420 正确答案:B 32.

(单选)下列语句创建对象的总个数是:()。 String s=”a”+”b”+”c”+”d”+”e”; A.1 B.2 C.3 D.4 正确答案:A 33.

(单选)下面的代码用于对数组arr实现冒泡排序: for (int i = 0; i < arr.length - 1; i++) { boolean isSwap = false; 空白处 if (!isSwap) break; } 下列选项中,空白处可以填入的代码是:()。

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; } }

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; } } 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; } } 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; } } 正确答案:A 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”,那么<插入代码>处应填入代码是: A.p.setWeight(420); B.Payload.setWeight(420); C.p = new Payload(420);

D.p = new Payload(); p.setWeight(420); 正确答案:A 35.

(单选)下列代码运行的结果是()。 public class Base { public static final String FOO = \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 = \ A.foofoofoofoofoo B.foobarfoobarbar C.foobarfoofoofoo D.foobarfoobarfoo 正确答案:D 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类的是: A.public class Circle implements Shape { private int radius; } B.public abstract class Circle extends Shape { private int radius; } C.public class Circle extends Shape { private int radius; public void draw(); }