测试组JAVA测试题U2样卷(有答案和描述)

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
a) true true true b) true false false c) false true true d) false false false
18) 下面的结果是什么?B(考核继承语法)
//定义超类 superA class superA { int i = 100; void fun() { System.out.println(“This is superA”); } } //定义 superA 的子类 subB class subB extends superA { int m = 1; void fun() { System.out.println(“This is subB”); } } //定义 superA 的子类 subC class subC extends superA { int n = 1; void fun() { System.out.println(“This is subC”); } }
a) public void getNumber() throw Exception{} b) public void getNumber() throw Exception{} c) public void getNumber() throws exception{} d) public void getNumber()throws Exception{}
} void stringModifier(String theString ) { theString=theString+"2"; System.out.println(theString); }
}
a) 12 1 b) 12 12 c) 1 12 d) 1 1
8) 请选择正确的答案:abde(用于考核二维数组的使用)
a) true true b) true false c) false true d) false false
17) 下面的结果是什么?D(扰乱题考核 String 语法)
String s0=”kvill”; String s1=new String(”kvill”); String s2=”kv” + new String(“ill”); System.out.println( s0==s1 ); System.out.println( s0==s2 ); System.out.println( s1==s2 );
}
a) 程序不能编译,因为 main 方法不正确. b) 程序可以编译,但不能正确运行,因为找不到对应的 main 方法. c) 程序可以编译,但不能正确运行,因为对应方法不是 public 的. d) 程序可以编译,也可以运行,但不会显示任何内容. e) 程序可以编译,也可以运行,显示内容为”hello”.
}
a) helloworld b) worl c) oworl d) orld
21) 下面代码的输出结果是?B(考核继承和多态)
public class Test { public static void main(String[] arg) { Super s = new Sub(); s.show();
a(用于考核 java 9) Math.round(11.5)等於多少? Math.round(-11.5)等於多少?
工具类,略难)
a) 12 -11 b) 11 -11 c) 12 -12 d) 11 -12
d(考核 java 10) 构造器 Constructor 是否可被 override? 是否可以继承 String 类?
class Test {
public static void main(String[] args) {
superA a; subB b = new subB(); subC c = new subC(); a=b; a.fun(); (1) a=c; a.fun(); (2) } }
a) This is subB This is subB
a(基础语法) 12) 接口是否可继承接口? 抽象类是否可实现(implements)接口?
a) 是 是 b) 是 否 c) 否 是 d) 否 否
C(考核数 13) 数组有没有 length()这个方法? String 有没有 length()这个方法?
据类型,包装类型与引用类型)
a) 有 有 b) 有 否 c) 否 有 d) 否 否
} } class Super {
static public void show(){System.out.println("in Super");} } class Sub extends Super {
static public void show(){System.out.println("in Sub");} }
26) 把一个字符串值转化为一个数值型的方法是:a(包装类型语法)
a) Integer.ParseInt(); b) Integer.valueOf(); c) Integer.IntValue(); d) Integer.IntOf();
a) helloworld b) worl c) oworl d) orld
20) 下面代码的输出结果是?A(考核字符串拼接)
class Test{ public static void main(String [] args){ StringBuffer s = new StringBuffer("hello"); s.append("world"); System.out.println(s.toString()); }
a) in Sub b) in Super c) “” d) null
22) 下面代码的结果是?A(Collection 集合语法)
Set 集合类中不允许有重复对象吗? List 里可以保存重复对象吗?
a) 是 可以 b) 是 不可以 c) 否 可以 d) 否 不可以
23) 下列写法正确的:d(异常基础语法)
a) 10 b) 0 c) 20 d) null
6) 下面哪些 main()方法写正确?Abe(用于考核基础语法)
a) public static void main(String [] args){} b) public static void main(String args []){} c) public int void main(String args []){} d) public static void main(int args []){} e) public static void main(String version []){}
5) 下面程序将输出的值是多少?C(用于考核构造方法)
class Test{ int myIntVar=10; Test(){ myIntVar=20;
} public static void main(String args[]){
System.out.println(new Test().myIntVar); } }
14) 下面的写法有错吗?B(考核数据类型语法)
1、short s1 = 1; s1 = s1 + 1; 2、short s1 = 1; s1 += 1;
a) 有 有 b) 有 否
c) 否 有 d) 否 否
15) 下面的结果是什么?B(考核引用类型与元数据类型的区
别)
int a=10; int b=10; a= =b 将输出? String a=new String("foo"); String b=new String("foo"); a==b 将输出?
24) 使用()方法可以获取 Calendar 实例。B(考核时间工具类,略
难)
a) get() b) getInstance() c) getTime() d) equals()
D(集合 25) 可用于创建动态数组的是? 哪个对象可以用键/值的形式保存数据。
语法)
a) ArrayList ArrayList b) LinkedList HashMap c) HashTable Collection d) ArrayList HashMap
}
a) A compiler error.
b) A runtime error.
c) 10 d) 20
4) 在 JAVA 数组里所有的元素必须属于同种类型?在集合里(例如 ArrayList)
里所有的元素可以为不同类型?A(用于考核数组与集合的区
别)
a) True True b) False True c) True False e) False False
语法描述、类型与构造的区别)
a) 是 是 b) 是 否 c) 否 是 d) 否 否
b(考 11) swtich 是否能作用在 byte 上,是否能作用在 long 上,是否能作用在 String 上?
核 swtich 语法,略难)
a) 是 是 是 b) 是 否 是 c) 否 是 否 d) 是 否 否
7) 下面程序将输出的值是多少?A(用于考核变量的运用和字符
串拼接)
class Test{ String myString ="1"; public static void main(String args[]){ Test myObj=new Test(); myObj.stringModifier(myObj.myString); System.out.println(myObj.myString);
b) This is subB This is subC
c) This is subA This is subA d) This is subA This is subB This is subC
19) 下面代码的输出结果是?B(考核字符串用法)
String s = "helBiblioteka Baiduoworld"; s=s.substring(5,9); System.out.println(s);
针 对 以 下 题 目 请 选 择 正 确 答 案( 每 道 题 目 有 一 个 或 多 个 正 确 的 答 案 )。 针 对 每 一 道 题 目 ,所 有 答 案 都 选 对 ,则 该 题 得 分 ,所 选 答 案 错 误 或 不 能 选出所有正确答案,则该题不得分,以下每题 2 分。
1) 选择不符合命名规范的变量 ?Abd(用于考核基础语法)
3) 下面的程序将会输出什么结果 ? A(用于考核数据类型的
应用)
class Test{ public static void main(String [] args){ long size =10; int [] array=new int[size]; size=20; System.out.println(“array.length”); }
a) float f[][]=new float[6][6]; b) float []f[]=new float[6][6]; c) float f[][]=new float[][6]; d) float [][]f=new float[6][6]; e) float [][]f=new float[6][];
a) here: b) _there: c) this: d) that: e) 2tolodds:
2) 当你试图编译并运行下面的 Test 类时,java 编译器将会出现什么问题?
B(用于考核 main 方法的使用和细节查错能力)
Class Test { public static void main(){ System.out.println(“hello”); }
a) true true b) true false c) false true d) false false
16) 下面的结果是什么?A(考核拼接语法,扰乱题)
String s0=”kvill”; String s1=”kvill”; String s2=”kv” + “ill”; System.out.println( s0==s1 ); System.out.println( s0==s2 );
相关文档
最新文档