c2 number , c3 number , constraint test_c3_uk unique(c2,c3)); D.
create table test(
c1 number constraint test_c1_pk primary key, c2 number constraint test_c2_uk unique, c3 number constraint test_c3_uk unique); 正确答案:CD
40. 请看下列代码:
public class Key { private long id1; private long 1d2; // class Key methods }
程序员开发Key类,作为java.util.HashMap的key,那么Key应该覆盖的两个方法是: A. public int hashCode()
B. public boolean equals(Key k) C. public int compareTo(Object o) D. public boolean equals(Object o) 正确答案:AD
41. IO类实现了打开并读取一个文本文件,每次读取一行内容。将每行作为一个String字符串放入String数组里面返回。阅读代码并完成以下5题:
public class IO { public String[] read(InputStream in) throws IOException { String[] arr = new String[1]; String[] temp = null;
空白处1
String line =\ while ((空白处2) != null) { arr[arr.length - 1] = line; 空白处3 for (int i = 0; i < arr.length; i++) { temp[i] = arr[i]; } 空白处4 for (int i = 0; i < arr.length; i++) { arr[i] = temp[i]; }
}
arr = new String[temp.length - 1];
}
for (int i = 0; i < arr.length; i++) { arr[i] = temp[i]; } br.close(); return arr; }
public static void main(String[] args) throws IOException { String[] arr = new IO().read(new FileInputStream(\ System.out.println(arr); }
空白处5
System.out.println(str);
(1). 下列选项中,能填入空白处1的代码是( )
A. BufferedReader br = new BufferedReader(new InputStreamReader(in)); B. BufferedReader br = new BufferedReader(new FileReader(in)); C. FileReader br=new FileReader(in);
D. InputStreamReader br=new InputStreamReader(in); 正确答案:A
(2). 下列选项中,能填入空白处2的代码是( ) A. line = br.read(); B. line = br.readLine(); C. line = br.readString(); D. line = br.readUTF();
正确答案:B
(3). 下列选项中,能填入空白3的代码是( ) A. temp = new String[arr.length + 1]; B. temp = new String[arr.length]; C. temp = new String[arr.length-1]; D. temp = new String[arr.length/2];
正确答案:A
(4). 下列选项中,能填入空白处4的代码是( ) A. arr = new String[temp.length/2]; B. arr = new String[temp.length-1]; C. arr = new String[temp.length+1]; D. arr = new String[temp.length]; 正确答案:D
(5). 下列选项中,能填入空白处5的代码是( ) A. for (arr: String str) { B. for (arr[]:String str){ C. for (String str : arr) { D. for (String str : arr[]) { 正确答案:C
42. ScoreManager类实现了成绩管理系统。该系统有如下功能供选则:录入成绩,成绩列表,查询成绩,退出。当用户在控制台输入1,用户选择的功能为录入成绩;输入2,用户选择的功能为成绩列表;输入3,用户选择的功能为根据姓名查找成绩;输入4,退出。 ScoreManager类代码如下:
public class ScoreManager { public static void main(String[] args) { int numOfStudents = 10; //学生名字信息数组 String[] students = NameUtils.randomNames(numOfStudents); int[] scores = new int[numOfStudents];//学生成绩数组 //使用Scanner接收控制台的输入信息 空白处1 System.out.println(\欢迎进入成绩管理系统**********\ while (true) { System.out.println(\请选择功能:1——成绩录入,2——成绩列表,3——成绩查询,4——退出\ String c = scanner.next().trim(); if (\ System.out.println(\开始录入成绩: \ for (int i = 0; i < students.length; i++) { System.out.print((i + 1) + \学生姓名:\成绩:?\ //从控制台接收到学生成绩 空白处2 } System.out.println(\录入完毕。\ } else if (\ int avg = 0; for (int i = 0; i < scores.length; i++) { avg += scores[i]; } //计算学生的平均成绩 空白处3 System.out.println(StringUtils.rightPad(\编号\姓名\ + StringUtils.rightPad(\成绩\ System.out.println(StringUtils.repeat(\ for (int i = 0; i < students.length; i++) { System.out.println(StringUtils.rightPad(i + 1 + \10, \\StringUtils.rightPad(students[i], 10, \ } System.out.println(StringUtils.repeat(\
System.out.println(\平均成绩: \ }
else if (\ System.out.print(\请输入您要查询的学生姓名: \ String student = scanner.next().trim(); int i = 0; for (; i < students.length; i++) { //如果查找到某个学生的信息,退出当前循环 空白处4 }
if ( 空白处5 ) {
System.out.println((i + 1) + \学生姓名:\成绩:\scores[i]); } else { System.out.println(\对不起,找不到学员的信息。\ } } else if (\ System.out.println(\谢谢使用**********\ break; } } scanner.close(); } }
(1). 下列选项中,能填入空白处1的代码是( ) A. Scanner scanner = new Scanner(System.out); B. Scanner scanner = new Scanner(System.in);
C. Scanner scanner = new Scanner(new FileInputStream(System.in)); D. Scanner scanner = new Scanner(new FileOutputStream(System.out)); 正确答案:B
(2). 下列选项中,能填入空白处2的代码是( ) A. scores[i] = scanner.nextInt(); B. scores[i] = scanner.next();
C. scores[i] = scanner.nextDouble(); D. scores[i] = scanner.nextString(); 正确答案:A
(3). 下列选项中,能填入空白处3的代码是( ) A. avg *= scores.length; B. avg /= scores.length; C. avg *= scores.length-1; D. avg /= scores.length-1;