云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 1609第一次月考详细解析

1609第一次月考详细解析

  • 62 次阅读
  • 3 次下载
  • 2025/5/26 7:56:00

public static void main(String[] args) { A a1 = new A(); A a2 = new A(); A a3 = new A();

System.out.println(A.getInstanceCount()); } } A.该类编译失败 B.输出:1 C.输出:3 D.输出:0 正确答案:A

//在static方法中无法返回非static的变量由于static在调用时没有具体的对象,因此在static

方法中不能对非static成员(对象成员)进行访问。

15.(单选)下面for语句,存在编译错误的是()。 A.for( ; ; ){}//相当于while(true),死循环 B.for(int i=0; i < 100;i++){}

C.for(int i = 0, j=0; ;i++,j++){}//相当于while(true),死循环 D.for(int i = 0; i < 10){}//缺循环变量的变化 正确答案:D 16.

(单选)请看下列代码: interface Foo {

int bar(); }

public class Sprite { public int fubar(Foo foo) { return foo.bar(); } public void testFoo() { fubar( <插入代码> ); } }

使类Sprite编译通过,在<插入代码>处应填入的代码是: A.Foo { public int bar() { return 1; } } B.new Foo { public int bar() { return 1; } } C.new Foo() { public int bar(){return 1; } } D.new class Foo { public int bar() { return 1; } } 正确答案:C

// 接口无法实例化:fubar方法中需要传入一个Foo类型的参数,但是Foo只是一个接口,无法直接实例化对象,

因此在这里我们选择了匿名内部类进行实例化

17.

(单选)请看下列代码: public class Plant { private String name; public Plant(String name) {

this.name = name; }//Plant中的有参的构造方法 public String getName() { return name; } } class Tree extends Plant {

public void growFruit() { } public void dropLeaves() { } } 下列说法正确的是:

A. 在Tree类中添加代码:public Tree() { Plant(); },编译将通过 //子类构造方法中调用父类的构造方法,写法是:super(); 不写的话系统会默认有

B.在Plant类中添加代码:public Plant() { Tree(); },编译将通过 C.在Plant类中添加代码:public Plant() { this(”fern”); },编译将通//无参构造方法中调用有参的构造方法,可以。格子类的时候,有类似的例子

D.在Plant类中添加代码:public Plant() { Plant(”fern”); },编译将通过 正确答案:C 18.

(单选)请看下列代码编译和运行的结果是()。 interface DeclareStuff {

public static final int EASY = 3; void doStuff(int t); }

public class TestDeclare implements DeclareStuff { public static void main(String[] args) { int x = 5;

new TestDeclare().doStuff(++x); }

//调用方法,把++x(为6)传给了形参s,这时s为6 s = 6 + 3 + 7

void doStuff(int s) {//编译错误,方法缺public 修饰,接口的方法默认都是由public abstract 修饰的

s += EASY + ++s; //等同于s = s + EASY + (++s)

//用debug调试,非常容易看到结果的变化

System.out.println(\ A.s=14 B.s=16 C.s=10 D.编译失败

正确答案:D//如果没有编译错误,能输出s=16 19.

(单选)下列关于IDE开发环境Eclipse,说法错误的是:()。 A.Eclipse可以通过插件(plugin)的方式扩展其功能。

搜索更多关于: 1609第一次月考详细解析 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

public static void main(String[] args) { A a1 = new A(); A a2 = new A(); A a3 = new A(); System.out.println(A.getInstanceCount()); } } A.该类编译失败 B.输出:1 C.输出:3 D.输出:0 正确答案:A //在static方法中无法返回非static的变量由于static在调用时没有具体的对象,因此在static方法中不能对非static成员(对象成员)进行访问。 15.(单选)下面for语句,存在编译错误的是()。 A.for( ; ; ){}//相当于while(true),死循环 B.for(int i=0; i < 100;i++){} <

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com