JAVA选择题训练(2)

2019-01-10 14:14

A) char c=\ B) int i=12; C) float f=2.8; D)boolean b=null; 答案:B

下列语句片段的结果为 int result; int a=17,b=6;

result=(a%b>4)? a%b:a/b ; System,out.println(result);

A. 0 B. 1 C. 2 D. 5 答案:D 给出下面代码: public class Person{

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

以下那个说法正确?

A 编译时将产生错误; B 编译时正确,运行时将产生错误; C 输出零; D 输出空。 答案:C

以下代码的输出结果? public class Test{ static int x=5;

public static void main(String argv[]){

change(x); x++;

System.out.println(x); }

static void change(int m){ m+=2; } }

A) 7 B) 6 C) 5 D) 8 答案:B

以下代码的输出结果? public class Test{ int x=5;

public static void main(String argv[]){ Test t=new Test();

t.x++; change(t);

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

static void change(Test m){ m.x+=2; } }

A) 7 B) 6 C) 5 D) 8 答案:D

以下代码的输出结果? public class Test{

public static void main(String argv[]){ String x=\

change(x);

System.out.println(x); }

static void change(String m){ m=m+2; } }

A) hello B) hello2

C) 编译报错 D) 运行报错,不能将串与整数相加 答案:A 第三章

执行以下程序后,输出结果为 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. 编译错误 E. null 答案:A

执行以下程序后,输出结果为 public class My{ int value;

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

System.out.println(\ else

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

A. 0 B. 1 C. No Object D. 编译错误 E. null 答案:D

执行以下程序后,输出结果为 public class Q7 {

public Static void main(String args [] ) int d = 14;

Add x= new Add ( ); x.m(d);

System.out.println (d); } }

class Add {

public void m(int x) { x= x%5;

System.out.println (x); } }

A. 4 B. 14 C.4 D.14 E.2 14 4 4 14 14 答案:A

执行以下程序后,输出结果为 public class A { static int k=3;


JAVA选择题训练(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:Linux系统及编程基础习题答案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: