四川农业大学《JAVA语言基础(本科》)20年12月作业试题答案

上传人:奥**** 文档编号:152002451 上传时间:2020-11-20 格式:DOCX 页数:10 大小:14.43KB
返回 下载 相关 举报
四川农业大学《JAVA语言基础(本科》)20年12月作业试题答案_第1页
第1页 / 共10页
四川农业大学《JAVA语言基础(本科》)20年12月作业试题答案_第2页
第2页 / 共10页
亲,该文档总共10页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《四川农业大学《JAVA语言基础(本科》)20年12月作业试题答案》由会员分享,可在线阅读,更多相关《四川农业大学《JAVA语言基础(本科》)20年12月作业试题答案(10页珍藏版)》请在金锄头文库上搜索。

1、JAVA语言基础(本科)20年12月作业考核核对好题目下载试卷总分:100 得分:100一、单选题 (共 20 道试题,共 100 分)1.类Test1定义如下: public class Test1 public float aMethod(float a,float b) 将以下哪种方法插入行3是不合法的。( )A.public float aMethod(float a, float b,float c) B.public float aMethod(float c,float d) C.public int aMethod(int a, int b) D.private float a

2、Method(int a,int b,int c) 答案:B2.以下哪个表达式是不合法的( )A.String x=”Hello”; int y=9; x+=y;B.String x=”Hello”; int y=9; if(x= =y) C.String x=”Hello”; int y=9; x=x+y;D.String x=null; int y=(x!=null)&(x.length()0) ? x.length : 0答案:B3.编译运行以下程序后,关于输出结果的说明正确的是 ( )public class Conditionalpublic static void main(Str

3、ing args ) int x=4; System.out.println(“value is “+ (x4) ? 99.9 :9); A.输出结果为:value is 99.99B.输出结果为:value is 9C.输出结果为:value is 9.0D.编译错误答案:C4.执行完以下代码int x = new int25;后,以下哪项说明是正确的( )A.x24为0B.x24未定义C.x25为0D.x0为空答案:A5.类Test1定义如下: public class Test1public float aMethod(float a,float b) 将以下哪种方法插入行3是不合法的。

4、( )A.public float aMethod(float a, float b,float c) B.public float aMethod(float c,float d) C.public int aMethod(int a, int b) D.private float aMethod(int a,int b,int c) 答案:B6.编译并运行以下程序(命令:java TestClass 0),关于运行结果的描述以下哪个选项是正确的( ) class TestClass public static void main(String args) long i=0; try i=I

5、nteger.parseInt(args0); catch(Exception e) switch(i) case 0: System.out.A.编译出错B.打印出“0”C.打印出“1”D.打印出“default”答案:A7.main方法是Java Application程序执行的入口点,关于main方法的方法头以下哪项是合法的( )A.public static void main()B.public static void main(String args)C.public static int main(String arg)D.public void main(String arg

6、)答案:B8.以下哪项可能包含菜单条( )A.PanelB.FrameC.AppletD.Dialog答案:B9.执行完以下代码int x = new int25;后, 以下哪项说明是正确的( )A.x24为0B.x24未定义C.x25为0D.x0为空答案:A10.以下说法哪项是正确的( ) class MyListener extends MouseAdapter implements MouseListener public void mouseEntered(MouseEvent mev) System.out.println(Mouse entered.); A.以上代码可通过编译B.

7、不能通过编译,因为没有实现MouseListener接口中的所有方法C.不能通过编译,因为类头定义不能分行D.能通过编译,若组件用该类作为Mouse的监听者并且接收了mouse-exited事件,则在执行过程中会抛出异常答案:A11.5、编译运行以下程序后,关于输出结果的说明正确的是 ( ) public class Conditional public static void main(String args ) int x=4; System.out.println(“value is “+ (x4) ? 99.9 :9); A.输出结果为:value is 99.99B.输出结果为:va

8、lue is 9C.输出结果为:value is 9.0D.编译错误答案:C12.以下代码段执行后的输出结果为()int x=3; int y=10; System.out.println(y%x);A.0B.1C.2D.3答案:B13.一个线程的run方法包含以下语句,假定线程没有被打断,以下哪项是正确的( ) 1try 2 sleep(100); 3 catch(InterruptedException e) A.不能通过编译,因为在run方法中可能不会捕捉到异常。B.在第2行,线程将暂停运行,正好在100毫秒后继续运行。C.在第2行,线程将暂停运行,最多在100毫秒内将继续运行。D.在第

9、2行,线程将暂停运行,将在100毫秒后的某一时刻继续运行。答案:D14.以下选项中循环结构合法的是( )A.while (int i7) i+;System.out.println(“i is “+i); B.int j=3; while(j) System.out.println(“ j is “+j); C.int j=0; for(int k=0; j + k !=10; j+,k+) System.out.println(“ j is “+ j + “k is”+ k); D.int j=0; doSystem.out.println( “j i答案:C15.下列关于修饰符混用的说法,

10、错误的是( )A.abstract不能与final并列修饰同一个类B.abstract类中不可以有private的成员C.abstract方法必须在abstract类中D.staic方法中能处理非static的属性答案:D16.以下哪项可能包含菜单条()A.PanelB.FrameC.AppletD.Dialog答案:B17.以下代码完成画线功能,指出所画线的颜色()g.setColor(Color.red.green.yello.cyan); g.drawLine(0,0,100,100);A.redB.greenC.yelloD.cyan答案:D18.以下标识符中哪项是不合法的( )A.B

11、igMeaninglessNameB.$intC.1 stD.$1答案:C19.关于以下application的说明,正确的是() class StaticStuff static int x=10; static x+=5; public static void main(String args ) System.out.println(“x=” + x);A.4行与9行不能通过编译,因为缺少方法名和返回类型B.9行不能通过编译,因为只能有一个静态初始化器C.编译通过,执行结果为:x=5D.编译通过,执行结果为:x=3答案:C20.以下哪个接口的定义是正确的?( )A.interface A void print() ;B.abstract interface A void print() ;C.abstract interface A extends I1, I2 /I1、I2为已定义的接口 abstract void print() ;D.interface A void print();答案:D

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

最新文档


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

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