奥鹏东大东北大学作业答案奥鹏东大东北大学作业答案奥鹏东大东北大学 奥鹏东大东北大学作业答案奥鹏东大东北大学作业答案(单选题) 1: 奥鹏东大东北大学作业答案(单选题) 1: 下列代码的执行结果是 (单选题) 1: 下列代码的执行结果是 public class Test { public int aMethod() { static int i=0; i++; System.out.println(i); } public static void main(String args[]) { Test test = new Test(); 1: 编译错误 2: 0 3: 1 4: 运行成功,但不输出 标准选择: (单选题) 2: 下面哪一个类可以访问foo包中的所有变量? package foo; class a{int c} class b{private int d} class c{public int e} 1: class a 2: class b 3: class c 4: 都不能 标准选择: (单选题) 3: 下列哪个选项的java源文件代码片段是不正确的? 1: package testpackage; public class Test{ } 2: import java.io.*; package testpackage; public class Test{ } 3: import java.io.*; class Person{ } public class Test{ } 4: import java.io.*; import java.awt.*; public class Test{ } 标准选择: (单选题) 4: 下列类头定义中,错误的是( )。 1: class x { .... } 2: public x extends y { .... } 3: public class x extends y { .... } 4: class x extends y implements y1 { .... } 标准选择: (单选题) 5: 设有下面的一个类定义: class AA { static void Show( ){ System.out.println("我喜欢Java!"); } } class BB { void Show( ){ System.out.println("我喜欢C++!"); } } 若已经使用AA类创建对象a和BB类创建对象b,则下面哪一个方法调用是正确的:( ) 1: a.Show( ) b.Show( ) 2: AA.Show( ) BB.Show( ) 3: AA.Show( ) b.Show( ) 4: a.Show( ) BB.Show( ) 标准选择: (单选题) 6: 已知表达式int m[] = {0, 1, 2, 3, 4, 5, 6 }; 下面哪个表达式的值与数组下标量总数相等? 1: m.length() 2: m.length 3: m.length()+1 4: m.length+1 标准选择: (单选题) 7: 若有循环: int x=5,y=20; do{ y-=x; x++; }while(++x<--y);则循环体将被执行( )。 1: 0次 2: 1次 3: 2次 4: 3次 标准选择: (单选题) 8: 下面的语句的作用是:( )。 Vector MyVector = new Vector(100,50); 1: 创建一个数组类对象MyVector,有100个元素的空间,每个元素的初值为50。 2: 创建一个向量类对象MyVector,有100个元素的空间,每个元素的初值为50。 3: 创建一个数组类对象MyVector,有100个元素的空间,若空间使用完时,以50个元素空间单位递增。 4: 创建一个向量类对象MyVector,有100个元素的空间,若空间使用完时,以50个元素空间单位递增。 标准选择: (单选题) 9: 下面程序的输出结果是什么? String s= "ABCD"; s.concat("E"); s.replace('C','F'); System.out.println(s); 1: 编译错误,字符串是不可改变的 2: ABFDE 3: ABCDE 4: ABCD 标准选择: (单选题) 10: 给出下列代码,如何使成员变量m 被方法fun()直接访问? class Test { private int m; public static void fun() { ... } } 1: 将private int m 改为protected int m 2: 将private int m 改为 public int m 3: 将private int m 改为 static int m 4: 将private int m 改为 int m 标准选择: (单选题) 11: 如果你试图编译下面的代码会发生什么事? Class MyString extends String{ } 1: 代码编译成功 2: 代码不能编译,因为没有定义一个main()方法 3: 代码不能编译,因为String是abstract类型的 4: 代码不能编译,因为String是final类型的 标准选择: (单选题) 12: 下列程序段执行后t5的结果是( )。int t1 = 9, t2 = 11, t3=8;int t4,t5;t4 = t1 > t2 ? t1 : t2+ t1;t5 = t4 > t3 ? t4 : t3; 1: 8 2: 20 3: 11 4: 9 标准选择: (单选题) 13: 有下面的类: public class Example{ static int x[]=new int[15]; public static void main(String args[]){ System.out.println(x[5]); } } 下面的那些说法是正确的。 1: 编译时出错 2: 运行时出错 3: 输出0 4: 输出null 标准选择: (单选题) 14: 给定下面的类: public class Example{ String str=new String(“good”); char ch[]={'a','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); } public void 1: good and abc 2: good and gbc 3: test ok and abc 4: test ok and gbc 标准选择: (单选题) 15: 下面程序的输出结果是什么? class Foo{ static void change(String s){ s=s.replace('j','l'); } public static void main(String args[]){ String s="java"; change(s); System.out.println(s); } } 1: lava 2: java 3: 编译错误 4: 运行时出现异常 标准选择: (单选题) 16: 下面的代码段中,执行之后i 和j 的值是什么? int i = 1; int j; j = i++; 1: 1, 1 2: 1, 2 3: 2, 1 4: 2, 2 标准选择: (单选题) 17: 65. 已知有下列类的说明,则下列哪个语句是正确的? public class Test { private float f = 1.0f; int m = 12; static int n=1; public static void main(String arg[]) { Test t = new Test(); } } 1: t.f; 2: this.n; 3: Test.m; 4: Test.f; 标准选择: (单选题) 18: 给出下列代码,则数组初始化中哪项是不正确的? byte[] array1,array2[]; byte array3[][]; byte [][] array4; 1: array2 = array1 2: array2=array3 3: array2=array4 4: array3=array4 标准选择: (单选题) 19: 下面的哪些程序段可以正确地获得从命令行传递的参数的个数? 1: int count = args.length; 2: int count = args.length-1; 3: int count=0; while(args[count]!=null) count++; 4: int count=0;while (!(args[count].equals(“”))) count++; 标准选择: (单选题) 20: 以下由do-while语句构成的循环执行的次数是( )。 int k = 0; do { ++k; }while ( k < 1 ); 1: 一次也不执行 2: 执行1次 3: 无限次 4: 有语法错,不能执行 标准选择: (多选题) 1: 已知如下定义: String s = "story"; 下面哪些表达式是合法的? 1: s += "books"; 2: char c = s[1]; 3: int len = s.length; 4: String t = s.toLowerCase(); 标准选择: (多选题) 2: 已知如下代码: switch (m) { case 0: System.out.println("Condition 0"); case 1: System.out.println("Condition 1"); case 2: System.out.println("Condition 2"); case 3: System.out.println("Condition 3");break; default: System.out.println("Other Condition"); } 当m 的 1: 0 2: 1 3: 2 4: 3 5: 4 F: 以上都不是 标准选择: (多选题) 3: 请选出创建数组的正确语句。 1: float f[][] = new float[6][6]; 2: float []f[] = new float[6][6]; 3: float f[][] = new float[][6]; 4: float [][]f = new float[6][6]; 标准选择: ,,D (多选题) 4: String s=”Example String”; 下面哪些语句是正确的? 1: s>>>=3; 2: int i=s.length(); 3: s[3]=”x”; 4: String short_s=s.trim(); 5: String t=”root”+s; 标准选择: (多选题) 5: 假定文件名是“Fred.java”,下面哪个是正确的类声明。 1: public class Fred{ public int x = 0; public Fred (int x){ this.x=x; } } 2: public class fred{ public int x = 0; public Fred (int x){ this.x=x; } } 3: public class Fred extends MyBaseClass{ public int x = 0; } 标准选择: (多选题) 6: 在如下源代码文件Test.java中, 哪个是正确的类定义? 1: public class test { public int x = 0; public test(int x) { this.x = x; } } 2: public class Test{ public int x=0; public Test(int x) { this.x = x; } } 3: public class Test extends T1, T2 { public int x = 0; public Test (int x) { this.x = x; } } 4: public class 标准选择: (多选题) 7: 如果有以下代码,哪几个数字能产生输出 "Test2" 的结果? Switch(x){ case 1: System.out.println("Test1"); case 2: case 3: System.out.println("Test2"); break;} System.out.println("Test3"); } 1: 0 2: 1 3: 2 4: 3 标准选择: (多选题) 8: 下面的哪些程序片断可能导致错误。 1: String s="Gonewiththewind"; String t="good"; String k=s+t; 2: String s="Gonewiththewind"; String t; t=s[3]+"one"; 3: String s="Gonewiththewind"; String standard=s.toUpperCase(); 4: String s="homedirectory"; String t=s-"directory". 标准选择: (多选题) 9: 已知如下类说明: public class Test { private float f = 1.0f; int m = 12; static int n=1; public static void main(String arg[]) { Test t = new Test(); // 程序代码… } } 如下哪个使用是正确的? 1: t.f 2: this.n 3: Test.m 4: Test.n 标准选择: (多选题) 10: 已知如下代码: public class Test { public static void main(String arg[]) { int i = 5; do { System.out.println(i); } while (--i>5) System.out.println("finished"); } } 执行后的输出结果包括什么? 1: 5 2: 4 3: 6 4: finished 5: 什么都不输出 标准选择: (责任编辑:admin)要这答案加QQ:800020900 或加微信:q800020900 获取 |