东大-19秋学期《JAVA语言程序设计Ⅰ》在线平时作业1答案

上传人:you7****5932 文档编号:139672277 上传时间:2020-07-23 格式:DOCX 页数:9 大小:14.71KB
返回 下载 相关 举报
东大-19秋学期《JAVA语言程序设计Ⅰ》在线平时作业1答案_第1页
第1页 / 共9页
东大-19秋学期《JAVA语言程序设计Ⅰ》在线平时作业1答案_第2页
第2页 / 共9页
亲,该文档总共9页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《东大-19秋学期《JAVA语言程序设计Ⅰ》在线平时作业1答案》由会员分享,可在线阅读,更多相关《东大-19秋学期《JAVA语言程序设计Ⅰ》在线平时作业1答案(9页珍藏版)》请在金锄头文库上搜索。

1、19秋学期JAVA语言程序设计在线作业1试卷总分:100 得分:100一、单选题 (共 20 道试题,共 60 分)1.如果你试图编译下面的代码会发生什么事? Class MyString extends String A.代码编译成功B.代码不能编译,因为没有定义一个main()方法C.代码不能编译,因为String是final类型的D.代码不能编译,因为String是abstract类型的答案:C2.已知表达式int m = 0, 1, 2, 3, 4, 5, 6 ; 下面哪个表达式的值与数组下标量总数相等?A.m.length()B.m.lengthC.m.length()+1D.m.l

2、ength+1答案:B3.若有循环: int x=5,y=20; do y-=x; x+; while(+x-y);则循环体将被执行( )。A.0次B.1次C.2次D.3次答案:C4.下面程序的输出结果是什么? class C1 static int j=0; public void method(int a) j+; class Test extends C1 public int method() return j+; public void result() method(j); System.out.println(j+method(); public static void main

3、(String args) new TeA.0B.1C.2D.3答案:C5.下面程序的输出结果是什么? class Happy public static void main(String args) int i =1; int j = 10; do if ( i+ j-) continue; while ( i 5 ); System.out.println ( i+ +j ); A.6 4B.5 6C.5 5D.5 4答案:B6.给出如下代码: class Test private int m; public static void fun() / some code. 如何使成员变量m被

4、函数fun()直接访问?A.将private int m 改为protected int mB.将private int m 改为 public int mC.将private int m 改为 static int mD.将private int m 改为 int m答案:C7.给出下列代码,如何使成员变量m 被方法fun()直接访问? class Test private int m; public static void fun() . A.将private int m 改为protected int mB.将private int m 改为 public int mC.将private

5、 int m 改为 static int mD.将private int m 改为 int m答案:C8.选择正确的叙述. class Happy extends Frame Happy() SetLayout(new GridLayout(2,2); Panel p1 = new Panel(); add(p1); p1.add( new Button(One); Panel p2 = new Panel(); add(p2); p2.add( new Button(Two); add( new Button(Three); add( new Button(Four); sA.当frame调

6、整大小时,按钮Three和Four 的大小也将调整。B.当frame调整大小时,所有按钮的大小都将调整。C.当frame调整大小时,按钮Two和Four 的大小也将调整。D.当frame调整大小时,按钮One和Two 的大小也将调整。答案:A9.以下由do-while语句构成的循环执行的次数是( )。 int k = 0; do +k; while ( k t2 ? t1 : t2+ t1;t5 = t4 t3 ? t4 : t3;A.8B.20C.11D.9答案:B20.已知如下代码: boolean m = true; if ( m = false ) System.out.println

7、(False); else System.out.println(True); 执行结果是什么?A.运行时出错B.编译时出错C.TrueD.False答案:C二、多选题 (共 10 道试题,共 40 分)21.在如下源代码文件Test.java中, 哪个是正确的类定义?A.public class test public int x = 0; public test(int x) this.x = x; B.public class Test public int x=0; public Test(int x) this.x = x; C.public class Test extends T

8、1, T2 public int x = 0; public Test (int x) this.x = x; D.public class答案:BD22.下面代码执行后的输出是什么? outer: for(int i=0;i3; i+) inner: for(int j=0;j2;j+) if(j=1) continue outer; System.out.println(j+ “ and “+i); A.0 and 0B.0 and 1C.0 and 2D.1 and 0E.1 and 1F.1 and 2G.2 and 0H.2 and 1I.2 and 2答案:ABC23.已知如下类定

9、义: class Base public Base () /. public Base ( int m ) /. protected void fun( int n ) /. public class Child extends Base / member methods 如下哪句可以正确地加入子类中?A.private void fun( int n ) /.B.void fun ( int n ) /. C.protected void fun ( int n ) /. D.public void fun ( int n ) /. 答案:CD24.已知如下类说明: public class Test private float f = 1.0f; int m = 12; static int n=1; public static void main(String arg) T

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 高等教育 > 习题/试题

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号