自用 | bb选择题 assgn6(Object Oriented Thinking)

这是一组关于Java编程的基础选择题,涵盖了String、StringBuilder、BigInteger等知识点,包括字符串替换、性能优化、方法调用等多个方面。
摘要由CSDN通过智能技术生成

问题 1

The following program displays __________.

public class Test { 

  public static void main(String[] args) {

    String s = "Java";

    StringBuilder buffer = new StringBuilder(s);

    change(buffer);

    System.out.println(buffer);

  }

 

  private static void change(StringBuilder buffer) {

    buffer.append(" and HTML");

  }

}

A.and HTML

B.Java

C.nothing is displayed

D.Java and HTML

  

问题 2

Assume StringBuilder strBuf is "ABCCEFC", after invoking _________, strBuf contains "ABTTEFT".

A.strBuf.replace('C', "TT")

B.strBuf.replace('C', 'T')

C.strBuf.replace(2, 7, "TTEFT")

D.strBuf.replace("CC", "TT")

E.strBuf.replace("C", "T")

问题 3

If your string does not require any changes, you should use String rather than StringBuffer to improve performance.

A.false

B.true

问题 4

What is the output of the following code?

public class Test { 

  public static void main(String[] args) {

    String s1 = "Welcome to Java!";

    String s2 = "Welcome to Java!";



    if (s1 == s2)

      System.out.println("s1 and s2 reference to the same String object");

    else

      System.out.println("s1 and s2 reference to different String objects");

  }

}

A.s1 and s2 reference to different String objects

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值