String a = “ABCD”;  String b = a.toLowerCase();  b.replace(‘a’, ‘d’);  b.replace(‘b’, ‘c’);  System.out.println(b);   What is the result? () A、 abcdB、 ABCDC、 dccdD、 dcbaE、 Compilation fails.F、 An exception is thrown at runtime.

题目

String a = “ABCD”;  String b = a.toLowerCase();  b.replace(‘a’, ‘d’);  b.replace(‘b’, ‘c’);  System.out.println(b);   What is the result? () 

  • A、 abcd
  • B、 ABCD
  • C、 dccd
  • D、 dcba
  • E、 Compilation fails.
  • F、 An exception is thrown at runtime.

相似考题
更多“String a = &ldqu”相关问题
  • 第1题:

    Given:Which regular expression, inserted at line 12, correctly splits test into "Test A", "Test B", and "Test C"?()

    A.String regex="";

    B.String regex=" .";

    C.String regex=".*";

    D.String regex="\\s";

    E.String regex="\\.\\s*";

    F.String regex="\\w[\.]+";


    参考答案:E

  • 第2题:

    下列程序段运行的结果为 public class Test{ static void print(String s,int i){ System.out.println("String:"+s+",int:"+i); } static void print(int i, String s){ System.out.println("int:"+i+",String:"+s); } public static void main(String [] args){ print(99,"Int first"); } }

    A.String:Stringfirst,int:11

    B.int:11,String:Int first

    C.String:String first,int:99

    D.int:99,String:int first


    正确答案:D
    解析:本题考查考生阅读程序的能力。JavaApplication都是以main()方法作为入口,首先执行的是print(99,“Intfirst”),根据构造方法的参数类型选择调用方法,这里调用的是print(inti,Strings)方法,因此输出的是int:99,String:Intfirst。

  • 第3题:

    已知String类定义如下:

    class String

    {

    public:

    String(const char *str = NULL); // 通用构造函数

    String(const String &another); // 拷贝构造函数

    ~ String(); // 析构函数

    String & perater =(const String &rhs); // 赋值函数

    private:

    char *m_data; // 用于保存字符串

    };

    尝试写出类的成员函数实现。


    正确答案:

     

    String::String(const char *str)
    {
    if ( str == NULL ) //strlen在参数为NULL时会抛
    异常才会有这步判断
    {
    m_data = new char[1] ;
    m_data[0] = '\0' ;
    }
    else
    {
    m_data = new char[strlen(str) + 1];
    strcpy(m_data,str);
    }
    }
    String::String(const String &another)
    {
    m_data = new char[strlen(another.m_data) + 1];
    strcpy(m_data,other.m_data);
    }
    String& String::operator =(const String &rhs)
    {
    if ( this == &rhs)
    return *this ;
    delete []m_data; //删除原来的数据,新开一块内

    m_data = new char[strlen(rhs.m_data) + 1];
    strcpy(m_data,rhs.m_data);
    return *this ;
    }
    String::~String()
    {
    delete []m_data ;
    }

  • 第4题:

    Given:Andthefollowingfivefragments:publicstaticvoidmain(String...a){publicstaticvoidmain(String.*a){publicstaticvoidmain(String...a){publicstaticvoidmain(String[]...a){publicstaticvoidmain(String...[]a){Howmanyofthecodefragments,insertedindependentlyatline2,compile?()

    A.0

    B.1

    C.2

    D.3

    E.4


    参考答案:D

  • 第5题:

    下面哪个是对字符串String的正确定义()。

    • A、String s1=null;
    • B、String s2=’null’;
    • C、String s3=(String)‘abc’;
    • D、String s4=(String)‘/uface’;

    正确答案:A

  • 第6题:

    下面哪些语句能够正确地生成5个空字符串?()

    • A、String a[]=new String[5];for(int i=0;i<5;a[i++]=“”);
    • 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);

    正确答案:A,B

  • 第7题:

    下面字符串中非法字符串为().

    • A、’a string’
    • B、"a string"
    • C、’It is a’string’’
    • D、"It is a’string.’"

    正确答案:C

  • 第8题:

    在JAVA EE中,request对象的()方法可以获取页面请求中一个表单组件对应多个值时的用户的请求数据。

    • A、String getParameter(String name)
    • B、String[] getParameter(String name)
    • C、String getParameterValuses(String name)
    • D、String[] getParameterValues(String name)

    正确答案:D

  • 第9题:

    下列Map的泛型声明中正确的是哪项?()  

    • A、Map〈String〉
    • B、Map〈String,String〉
    • C、Map(String)
    • D、Map()

    正确答案:B

  • 第10题:

    11. String test = “Test A. Test B. Test C.”;  12. // insert code here  13. String[] result = test.split(regex);  Which regular expression inserted at line 12 will correctly split test into “Test A,” “Test B,” and “Test C”?()

    • A、 String regex = “”;
    • B、 String regex = “ “;
    • C、 String regex = “.*“.
    • D、 String regex = “//s”
    • E、 String regex = “//.//s*”;
    • F、 String regex = “//w[ /.] +“;

    正确答案:E

  • 第11题:

    问答题
    String s = new String("xyz");创建了几个String Object?

    正确答案: 两个对象,一个是“xyx”,一个是指向“xyx”的引用对象s。
    解析: 暂无解析

  • 第12题:

    单选题
    下列不是 String 类的方法的是()
    A

    charAt(int index)

    B

    indexOf(String s)

    C

    beginWith(String s)

    D

    endsWith(String s)


    正确答案: D
    解析: 暂无解析

  • 第13题:

    下列的哪个程序段可能导致错误? ( )

    A.String s="hello"; String t="good"; String k=s+t;

    B.String s="hello"; String t; t=s[3]+"one";

    C.String s="hello"; String standard=s.toUpperCase();

    D.String s="hello"; String t=s+"good";


    正确答案:B

  • 第14题:

    下列字符串中非法字符串为( )。

    A.’a string’

    B.’It is a’string’.’

    C.”a string”

    D.”It is a’string”


    正确答案:B

  • 第15题:

    编写类 String 的构造函数、析构函数和赋值函数

    已知类 String的原型为:

    class String

    {

    public:

    String(const char *str = NULL); // 普通构造函数

    String(const String &other); // 拷贝构造函数

    ~ String(void); // 析构函数

    String & perate =(const String &other); // 赋值函数

    private:

    char *m_data; // 用于保存字符串

    };

    请编写 String的上述 4 个函数。


    正确答案:
     

  • 第16题:

    下面的哪些程序片断可能导致错误() 

    • A、String s = "Gone with the wind";  String t = " good ";  String k = s + t;
    • B、String s = "Gone with the wind";  String t;  t = s[3] + "one";
    • C、String s = "Gone with the wind";  String standard = s.toUpperCase();
    • D、String s = "home directory"; String t = s - "directory"

    正确答案:B,D

  • 第17题:

    下列不是 String 类的方法的是()

    • A、charAt(int index)
    • B、indexOf(String s)
    • C、beginWith(String s)
    • D、endsWith(String s)

    正确答案:C

  • 第18题:

    执行语句“stringstr("abc");”时,系统会自动调用string类的构造函数()。

    • A、string()
    • B、string(constchar*s)
    • C、string(conststring&str)
    • D、string(size_typen,charc)

    正确答案:B

  • 第19题:

    有声明语句:delegate void TimeDelegate(string s),则以下语句可以和委托TimeDelegate绑定的方法是()

    • A、 void f(){  }
    • B、 string f(){  }
    • C、 void f(string a){  }
    • D、 string f(string a){  }

    正确答案:C

  • 第20题:

    String s=new String("xyz");创建了几个String Object?


    正确答案: 两个或一个,”xyz”对应一个对象,这个对象放在字符串常量缓冲区,常量”xyz”不管出现多少遍,都是缓冲区中的那一个。New String每写一遍,就创建一个新的对象,它一句那个常量”xyz”对象的内容来创建出一个新String对象。如果以前就用过’xyz’,这句代表就不会创建”xyz”自己了,直接从缓冲区拿。

  • 第21题:

    Which of the following fragments might cause errors?()    

    • A、 String s = "Gone with the wind";String t = " good ";String k = s + t;
    • B、 String s = "Gone with the wind";String t;t = s[3] + "one";
    • C、 String s = "Gone with the wind";String standard = s.toUpperCase();
    • D、 String s = "home directory";String t = s - "directory";

    正确答案:B,D

  • 第22题:

    单选题
    下面哪个方法设置MIME类型?()
    A

    setHeader(String headerName,String headerValue)

    B

    setContentType(String mimeType)

    C

    setContentLength(int length)

    D

    addCookie(Cookie c)

    E

    addHeader(String name,String value)


    正确答案: E
    解析: 暂无解析

  • 第23题:

    单选题
    11. String test = “Test A. Test B. Test C.”;  12. // insert code here  13. String[] result = test.split(regex);  Which regular expression inserted at line 12 will correctly split test into “Test A,” “Test B,” and “Test C”?()
    A

     String regex = “”;

    B

     String regex = “ “;

    C

     String regex = “.*“.

    D

     String regex = “//s”

    E

     String regex = “//.//s*”;

    F

     String regex = “//w[ /.] +“;


    正确答案: D
    解析: 暂无解析

  • 第24题:

    单选题
    Given: Which regular expression, inserted at line 12, correctly splits test into "Test A", "Test B", and "Test C"?()
    A

    String regex="";

    B

    String regex=" .";

    C

    String regex=".*";

    D

    String regex="//s";

    E

    String regex="//.//s*";

    F

    String regex="//w[/.]+";


    正确答案: B
    解析: 暂无解析