文档库 最新最全的文档下载
当前位置:文档库 › 2012JAVA复习题及答案

2012JAVA复习题及答案

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(&uot;String 2&uot;);

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(&uot;The String No.1 is &uot;+s1);

System.out.println(&uot;The String No.2 is &uot;+s2);

System.out.println(&uot;The String No.3 is &uot;+s3);

System.out.println(&uot;The String No.4 is &uot;+s4);

System.out.println(&uot;The String No.5 is &uot;+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

相关文档
相关文档 最新文档