java试题

8 篇文章 0 订阅
7 篇文章 0 订阅
  1. **在Java中, 以下选项中( ) 的数据可以存放在一个数组中. **
    A."买羊肉串不?“,1,0
    B.10,-2-,“30
    C.true,6,8”
    D.6,30,20

  2. **在Java中, 已知定义数组int[] m = {0,1,2,3,4,5,6},以下选项中( ) 可以获得数组长度. **
    A.m.length()
    B.m.length
    C.m.length()+1
    D.m.length+1

  3. 在Java中, 创建数组的代码正确的是( ) .
    A.int[] ages=new int[1,2,3];
    B.int ages=new int[]{1,2,3};
    C.int ages[]={1,2,3,};
    D.int[] ages=[1,2,3];

  4. 在Java中, 以下代码实现的功能是( ).

public class Test {
    public static void main(String[] args) {
        int[] scores=new int []{99,95,91,87,85};
        int temp=scores[0];
        for (int index=1;index<5;index++){
            if (scores[index]<temp){
                temp=scores[index];
            }
        }
        System.out.println(temp);
    }
}

A.求最大数
B.求最小数
C.找到数组最后一个元素
D.编译出错

  1. 在Java中, 以下代码的运行结果是( ).
public class Test {
    public static void main(String[] args) {
        int[] a=new int[3];
        int[] b=new int[]{1,2,3,4,5};
        a=b;
        for (int i=0;i<b.length;i++){
            System.out.print(a[i]+" ");
        }
    }
}

A.123
B.程序报错
C.12345
D.00000

  1. 在Java中, 符合二重循环的语法是( ) .
A.while(循环条件){
		  if (判断条件){
		  //代码块
		  	}
		  }
		  
 B.while(循环条件){
 //代码块
 }
	 while(循环条件){
	 //代码块
	 }
 c. if (判断条件){
		 for(循环条件){
		  //代码块
    	}
	}
D.for(循环条件){
	while(循环条件){
	}
}

  1. 在Java中, 以下代码的运行结果是( ).
public static void main(String[] args) {
        int j=0;
        for (int i=1;i<=;i++){
            j=1;
            while (j<=i){
                System.out.print(j);
                j++;
            }
            System.out.println("\n");
        }
    }

A .*
  **
  ***
  ****
B. ****
  ***
  ***
  **
  *
C.1
  12
  123
  1234
D.1
  22
  333
  4444
}

  1. 在Java中, 以下代码的运行结果是( ).
    public static void main(String[] args) {
    int count=0;
    for (int i=3;i>0;i–){
    for (int j=1;j<3;j++){
    count++;
    }
    }
    System.out.println(count);
    }
    A.6
    B.7
    C.8
    D.9
  2. **在Java中, 以下说法正确的是( ). **
    A.程序执行到break语句时一定会结束所有循环
    B.程序执行到continue语句时会结束当前循环,即continue语句所在的循环
    C.continue和break语句可以出现在同一个循环体
    D.continue和break语句作用相同
  3. 在Java中, 以下代码的运行结果是( ).
  public static void main(String[] args) {
        int count=0;
        for (int i =0;i<10;i++){
            for (int j=0; j<10;j++){
                if (j%2==0){
                    continue;
                }if (j==7){
                    break;
                }else {
                    count++;
                }
            }
        }
        System.out.println(whb);
    }
}

A.20
B.30
C.40
D.50

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值