达内第一次JAVA考试题(4)

2018-12-23 23:32

A. 0 B. 99 C. 100 D. 101

正确答案:A 31.

请看下列代码: 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 A.

p.setWeight(420);

B.

Payload.setWeight(420); C.

p = new Payload(420); D.

p = new Payload(); p.setWeight(420);

正确答案:A 32.

请看下列程序的输出结果是:d public class Item { private String desc;

public String getDescription() { return desc; }

public void setDescription(String d) { desc = d; }

public static void modifyDesc(Item item, String desc) { item = new Item();

item.setDescription(desc); }

public static void main(String[] args) { Item it = new Item();

it.setDescription(\ Item it2 = new Item();

it2.setDescription(\

modifyDesc(it, \ System.out.println(it.getDescription()); System.out.println(it2.getDescription()); } } A.

Scrumdiddlyumptious Scrumdiddlyumptious B.

Scrumdiddlyumptious Fizzylifltng C.

Gobstopper

Scrumdiddlyumptious D.

Gobstopper

Fizzylifting

正确答案:D 33.

下列代码运行的结果是(d)。

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 = \} A.

foofoofoofoofoo B.

foobarfoobarbar C.

foobarfoofoofoo D.

foobarfoobarfoo

正确答案:D 34.

下列代码的输出结果是(c)。 abstract class Vehicle { public int speed() { return 0; } }

class Car extends Vehicle { public int speed() { return 60; } }

class RaceCar extends Car { public int speed() { return 150; } }

public class TestCar {

public static void main(String[] args) { RaceCar racer = new RaceCar(); Car car = new RaceCar();

Vehicle vehicle = new RaceCar();

System.out.println(racer.speed() + \ + vehicle.speed()); } } A. 0, 0,0 B. 150, 60, 0 C.

150, 150, 150 D.

抛出运行时异常

正确答案:C 35.

程序的执行结果是:a public class Test {

public static void main(String [] args){ String str1= new String(\ String str2 = new String(\ String str3=str1; if(str1.equals(str2)){

System.out.println(\ }else{

System.out.println(\ }

if(str1==str3){

System.out.println(\ }else{

System.out.println(\ } }

A. true true B. true false C. false true D. false false

正确答案:A 1.

请看下列代码: class One {

public One foo() { return this; } }

class Two extends One { public One foo() { return this; } }

class Three extends Two { <插入代码> }

下列选项中的代码,放置在<插入代码>处无编译错误的是:CD A.

public void foo() { } B.

public Object foo() { return this; } C.

public Two foo() { return this; } D.

public One foo() { return this; }

正确答案:CD


达内第一次JAVA考试题(4).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2017—2018学年度第一学期高二理科数学试卷含答案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: