Java 常用类习题一、选择题1. 下列 String 类的( )方法返回指定字符串的一部分(选择一项)A. extractstring()B. substring()C. Substring()D. Middlestring()2.下列哪一个是正确的( )A)HashTable 的关键字和值都允许为 nullB) HashTable 的关键字和值都不允许为 nullC)HashTable 的关键字允许为 null,值不允许为 nullD) HashTable 的关键字不允许为 null,值允许为 null3.对于下列代码:String str1="java”;String str2=”java";String str3=new String(”java");StringBuffer str4=new StringBuffer(”java”);以下表达式的值为 true 的是( )A) str1= =str2;B) str1= =str4; C) str2= =str3;D) str3= =str4;4.以下程序段输出结果的是( )public class Test { public static void main(String args[]){ String str="ABCDE”; str.substring(3); str.concat(”XYZ"); System。out。print(str); }}A) DE B) DEXYZ C) ABCDE D) CDEXYZ5.对于下列代码: public class Example{String str=new String(”hello");char ch[]={'d','b’,’c’};public static void main(String args[]){Example ex=new Example();ex。change(ex。str,ex.ch);System。out。println(ex。str+"and”+ex.ch[0]);}public void change(String str,char ch[]){str="world";ch[0]= ’a';}}输出结果是: ( )A) hello and dB) hello and aC) world and dD) world and a6.以下代码的运行结果是哪一项。( )public class StringTest{public static void mb_operate(String x,String y){x。concat(y);y=x;}public static void main (String args[]){String a=”A";String b="B";mb_operate(a,b);System。out。println(a+".”+b);}}A)A。AB)B.AC)A。BD)B.B7.以下代码的运行结果是哪一项.( )public class StringArray Test{public static void mb_swap(String [] s){if(s.length〈2) return;String t=s[0];s[0]=s[1];s[1]=t;}public static void main (String args[]){String [] s={"1”,”2"};mb_swap(s);System。out.print(s[0]+s[1]);}}A)20B)21C)22D)238.以下代码的运行结果是哪一项。( )public class TestGetChars{ public static void mai...