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

当前位置:首页 > Java基础练习题附答案

Java基础练习题附答案

  • 62 次阅读
  • 3 次下载
  • 2025/12/3 2:27:04

word格式

} }

以下那个说法正确? A. 编译时将产生错误;

B. 编译时正确,运行时将产生错误; C. 输出0; D. 输出null。

7)以下的程序的调试结果为? public class As{ int i = 10; int j; char z= 1; boolean b;

public static void main(String argv[]){ As a = new As(); a.amethod(); }

public void amethod(){ System.out.println(j);

System.out.println(b); } }

A.输出0 和false B. 输出0 和true C. 编译错误,b 未初始化 D. 编译错误, z 必须赋字符值 8)以下的程序的调试结果为? public class MyAr{

public static void main(String argv[]) { MyAr m = new MyAr(); m.amethod(); }

public void amethod(){ static int i;

System.out.println(i);

.. ..

word格式

} }

A. 输出结果为 0 B. 运行出错 C. 输出结果为 null D. 编译错误

9) 以下程序的运行结果为? class ValHold{

public int i = 10; }

public class ObParm{

public static void main(String argv[]){ ObParm o = new ObParm(); o.amethod(); }

public void amethod(){ int i = 99;

ValHold v = new ValHold(); v.i=30; another(v,i);

System.out.print( v.i ); }

public void another(ValHold v, int i){ i=0; v.i = 20;

ValHold vh = new ValHold(); v = vh;

System.out.print(v.i); System.out.print(i); } }

A.10030 B. 20030 C. 209930 D. 10020

八、继承与多态

1)以下程序调试结果为: class Base{

.. ..

word格式

Base(){

int i = 100; System.out.print (i); } }

public class Pri extends Base{ static int i = 200;

public static void main(String argv[]){ Pri p = new Pri(); System.out.print(i); } }

A.编译错误 B.200 C.100200 D.100 (2) 以下程序调试结果为: public class Test { int m=5;

public void some(int x) { m=x; }

public static void main(String args []) { new Demo().some(7); } }

class Demo extends Test { int m=8;

public void some(int x) { super.some(x); System.out.println(m); } }

A.5 B.8 C.7 D.无任何输出 E.编译错误 3) 试完成下述程序片段: public class Point() { int x,y;

public Point(int x,int y)

.. ..

word格式

{ =x; =y; } ...... }

A. Point.x Point.y B.无解 C. x1 y1 D.this.x this.y (4)考虑如下类: 1. class Test(int i) { 2. void test(int i) {

3. System.out.println(\4. }

5. void test(String s) {

6. System.out.println(\7. } 8.

9. public static void main(String args[]) { 10. Test t=new Test(); 11. char ch=\12. t.test(ch); 13. } 14. }

以下哪条为真?

A.行 5 不能通过编译,方法不能被覆盖.

B.行 12 不能通过编译, 因为没有一个test()方法含字符参数. C.代码可以编译但在12行将出现异常.

D.代码可以编译且产生如下输出: I am an int. E.代码可以编译且产生如下输出: I am a String. (5) 类Test1定义如下: 1.public class Test1{

2. public float aMethod(float a,float b){ } 3. 4.}

将以下哪种方法插入行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){ }

.. ..

搜索更多关于: Java基础练习题附答案 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

word格式 } } 以下那个说法正确? A. 编译时将产生错误; B. 编译时正确,运行时将产生错误; C. 输出0; D. 输出null。 7)以下的程序的调试结果为? public class As{ int i = 10; int j; char z= 1; boolean b; public static void main(String argv[]){ As a = new As(); a.amethod(); } public void amethod(){ System.out.println(j); System.out.printl

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价: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