java选择题要求答案..
一、选择1、下面哪些是java语言中的关键字?A.sizeofBabstractCNULLDNative2、下面语句哪个是正确的?Achar='abc';Blongl=o...
一、 选择
1、下面哪些是java语言中的关键字?
A.sizeof
B abstract
C NULL
D Native
2、下面语句哪个是正确的?
A char='abc';
B long l=oxfff;
C float f=0.23;
D double=0.7E-3;
3、以下程序测试String 类的各种构造方法,试选出其运行效果。
class STR{
public static void main(String args[]){
String s1=new String();
String s2=new String("String 2");
char chars[]={'a',' ','s','t','r','i','n','g'};
String s3=new String(chars);
String s4=new String(chars,2,6);
byte bytes[]={0,1,2,3,4,5,6,7,8,9};
StringBuffer sb=new StringBuffer(s3);
String s5=new String(sb);
System.out.println("The String No.1 is "+s1);
System.out.println("The String No.2 is "+s2);
System.out.println("The String No.3 is "+s3);
System.out.println("The String No.4 is "+s4);
System.out.println("The String No.5 is "+s5);
}
}
A The String No.1 is
The String No.2 is String 2
The String No.3 is a string
The String No.4 is string
The String No.5 is a string
B The String No.1 is
The String No.2 is String 2
The String No.3 is a string
The String No.4 is tring
The String No.5 is a string
C The String No.1 is
The String No.2 is String 2
The String No.3 is a string
The String No.4 is strin
The String No.5 is a string
D 以上都不对
4、下面语句段的输出结果是什么?
int i = 9;
switch (i) {
default:
System.out.println("default");
case 0:
System.out.println("zero");
break;
case 1:
System.out.println("one");
case 2:
System.out.println("two"); }
A default
B default, zero
C error default clause not defined
D no output displayed
二、多项选择
1、下面哪些语句能够正确地生成5个空字符串?
A String a[]=new String[5]; for(int i=0;i<5;a[++]="");
B String a[]={"","","","",""};
C String a[5];
D String[5]a;
E String []a=new String[5]; for( int i=0;i<5;a[i++]=null);
2、下面哪些选项将是下述程序的输出?
public class Outer{
public static void main(String args[]){
Outer: for(int i=0; i<3; i++)
inner:for(int j=0;j<3;j++){
if(j>1) break;
System.out.println(j+"and"+i);
}
}
}
A 0 and 0
B 0 and 1
C 0 and 2
D 0 and 3
E 2 and 2
F 2 and 1
G 2 and 0
3、下面哪个语句正确地声明一个整型的二维数组?
A int a[][] = new int[][];
B int a[10][10] = new int[][];
C int a[][] = new int[10][10];
D int [][]a = new int[10][10];
E int []a[] = new int[10][10]; 展开
1、下面哪些是java语言中的关键字?
A.sizeof
B abstract
C NULL
D Native
2、下面语句哪个是正确的?
A char='abc';
B long l=oxfff;
C float f=0.23;
D double=0.7E-3;
3、以下程序测试String 类的各种构造方法,试选出其运行效果。
class STR{
public static void main(String args[]){
String s1=new String();
String s2=new String("String 2");
char chars[]={'a',' ','s','t','r','i','n','g'};
String s3=new String(chars);
String s4=new String(chars,2,6);
byte bytes[]={0,1,2,3,4,5,6,7,8,9};
StringBuffer sb=new StringBuffer(s3);
String s5=new String(sb);
System.out.println("The String No.1 is "+s1);
System.out.println("The String No.2 is "+s2);
System.out.println("The String No.3 is "+s3);
System.out.println("The String No.4 is "+s4);
System.out.println("The String No.5 is "+s5);
}
}
A The String No.1 is
The String No.2 is String 2
The String No.3 is a string
The String No.4 is string
The String No.5 is a string
B The String No.1 is
The String No.2 is String 2
The String No.3 is a string
The String No.4 is tring
The String No.5 is a string
C The String No.1 is
The String No.2 is String 2
The String No.3 is a string
The String No.4 is strin
The String No.5 is a string
D 以上都不对
4、下面语句段的输出结果是什么?
int i = 9;
switch (i) {
default:
System.out.println("default");
case 0:
System.out.println("zero");
break;
case 1:
System.out.println("one");
case 2:
System.out.println("two"); }
A default
B default, zero
C error default clause not defined
D no output displayed
二、多项选择
1、下面哪些语句能够正确地生成5个空字符串?
A String a[]=new String[5]; for(int i=0;i<5;a[++]="");
B String a[]={"","","","",""};
C String a[5];
D String[5]a;
E String []a=new String[5]; for( int i=0;i<5;a[i++]=null);
2、下面哪些选项将是下述程序的输出?
public class Outer{
public static void main(String args[]){
Outer: for(int i=0; i<3; i++)
inner:for(int j=0;j<3;j++){
if(j>1) break;
System.out.println(j+"and"+i);
}
}
}
A 0 and 0
B 0 and 1
C 0 and 2
D 0 and 3
E 2 and 2
F 2 and 1
G 2 and 0
3、下面哪个语句正确地声明一个整型的二维数组?
A int a[][] = new int[][];
B int a[10][10] = new int[][];
C int a[][] = new int[10][10];
D int [][]a = new int[10][10];
E int []a[] = new int[10][10]; 展开
2个回答
展开全部
一
1 B
2 没有一个是正确的, 如果B你是手误0打成O的话, 则是B, 如果D你忘了定义变量的话, 则是D
3 你ABC三项 都一模一样, 都是正常答案..晕,你手打的?
4 B
二
1 B A里面[++]是怎么回事? BC肯定不行, 不是空字符串, 而是空, D肯定也是空的, 不是空字符串, 还会数组越界
2 A B C
3 C D
1 B
2 没有一个是正确的, 如果B你是手误0打成O的话, 则是B, 如果D你忘了定义变量的话, 则是D
3 你ABC三项 都一模一样, 都是正常答案..晕,你手打的?
4 B
二
1 B A里面[++]是怎么回事? BC肯定不行, 不是空字符串, 而是空, D肯定也是空的, 不是空字符串, 还会数组越界
2 A B C
3 C D
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询