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

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

Java基础练习题附答案

  • 62 次阅读
  • 3 次下载
  • 2025/12/3 0:09:55

word格式

A. for (int i=0; i < ia.length() -1; i++) B. for (int i=0; i< ia.length(); i++) C. for (int i=1; i < 4; i++) D. for (int i=0; i< ia.length;i++) 3)以下代码的调试结果? public class Q {

public static void main(String argv[]) { int anar[]= new int[5]; System.out.println(anar[0]); } }

A. 编译错误:anar 在引用前未初始化。 B. null C. 0 D. 5

4) 下列创建二维整型数组正确语句是: A. int a[][] = new int [10,10]; B. int a[10][10] = new int [][]; C. int a[][] = new int [10][10]; D. int []a[] = new int [10][10]; 5) 给出下面代码: public class Person{

static int arr[] = new int[10]; public static void main(String a[]) { System.out.println(arr[1]); } }

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

B. 编译时正确,运行时将产生错误; C. 输出0; D. 输出null。 6)设有如下说明:

char[] c = new char[100]; 则,c[50]的值为?

.. ..

word格式

A. 50 B. '/u0000' C. \D. 不定

E. 为null,直到被赋值。

7) 设有如下程序,其调试结果为: class Q2 {

public static void main(String[] args) { int[] seeds = {1,2,3,4,6,8}; int n= seeds.length; for (int i = 0; i < 3; i++) for (int k = 0; k< n-1; k++) seeds[k]= seeds[k+1]; for (int i = 0; i

A.输出: 1 2 3 4 6 B.输出: 4 6 8 8 8 C.输出: 2 3 4 6 8 D.输出: 2 3 4 6 七、类与对象编程

1) 以下程序的运行结果为: public class My{ int value;

public static void main(String args[]) { My x=new My(); if (x==null)

System.out.println(\ else

System.out.println(x.value); } }

A. 0 B. 1 C. No Object D. 编译错误(2)以下程序的运行结果为:

.. ..

E. null word格式

public class A { static int k=3;

public static void main(String[] args) { int k=4; A x1=new A(); x1.k++; A x2=new A(); x2.k++; k++;

System.out.println(x1.k); } }

A. 3 B. 4 C.5 D.6 E.7 3) 编译和运行以下程序结果为: public class A { static int k=3; static int m;

public static void main(String[] args) { k++; if (m==0)

System.out.println(k); else

System.out.println(B.k); k++; } }

class B {

static int k=6; }

A. 3 B. 4 C.5 D.编译错误 E.6 4)编译和运行以下程序结果为: 1: public class Q21 { 2: int maxElements; 3: void Q21() {

4: maxElements = 100;

.. ..

word格式

5: System.out.println(maxElements); 6: }

7: Q21(int i) { 8: maxElements = i;

9: System.out.println(maxElements); 10: }

11: public static void main(String[] args) { 12: Q21 a = new Q21(); 13: Q21 b = new Q21(999); 14: } 15: }

A. 输出100 和 999. B. 输出999 和 100.

C. 第2行出现编译错误,变量 maxElements未初始化. D. 12行出现编译错误. 5)以下的程序的调试结果为 public class Scope{ int i;

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

public static void amethod(){ System.out.println(i); } }

A. 输出结果为:0 B. 无输出 C. 编译错误 D. 输出null 6)给出下面代码: public class Person{

static int arr[] = new int[10]; public static void main(String a[]) { System.out.println(arr[1]);

.. ..

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

共分享92篇相关文档

文档简介:

word格式 A. for (int i=0; i < ia.length() -1; i++) B. for (int i=0; i< ia.length(); i++) C. for (int i=1; i < 4; i++) D. for (int i=0; i< ia.length;i++) 3)以下代码的调试结果? public class Q { public static void main(String argv[]) { int anar[]= new int[5]; System.out.println(anar[0]); } } A. 编译错误:anar 在引用前未初始化。 B. null C. 0 D. 5 4) 下列创建二维整型数组正确语句是: A. int a[][]

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