第一题:
public static void main (String[] args){
String[] fileNames = { \ \ for (String fileName : fileNames) { if (fileName.endsWith(\
System.out.print(fileName.substring(0, fileName.lastIndexOf(\ } } }
fileName.endsWith(\ 判断是否已\结尾
substring(0,4) 截取0-3的字符串,不包含4 lastIndexOf(\ 获取\最后一次出现的位置 答案:bcd cde efg
第二题:
public static void go(Long n) { System.out.println(\}
public static void go(Short n) { System.out.println(\}
public static void go(int n) { System.out.println(\}
public static void main(String[] args) { short y = 6; long z = 7; go(y); go(z); }
虽然y是short型的,但是编译器把它转换为int型 答案:int Long
第三题:
public static void main(String[] args){
String test = \ String regex = \
String[] result = test.split(regex); for(String s : result)
System.out.print(s + \ }
\\s 空白字符 *表示0个或任意多个 text.split(\按.拆分 答案: Test A Test B Test C
第四题:
public class AA{
private Long userId;
private String nickName; public Long getUserId() { return userId; }
public void setUserId(Long userId) { this.userId = userId; }
public String getNickName() { return nickName; }
public void setNickName(String nickName) { this.nickName = nickName; }
public static void main(String[] args){ AA m1=new AA();
m1.setUserId(new Long(100001)); m1.setNickName(\ AA m2=new AA();
m2.setUserId(new Long(100001)); m2.setNickName(\
System.out.println(m1==m2);
System.out.println(m1.equals(m2)); }
equals方法返回值也是return m1==m2 答案:false false
第五题
运行下列代码,输出为false的是:()。
A.String st1 = \