达内jsd1510第一次月考题,java第一阶段面向对象语法基础学习知识考试试题_第1页
达内jsd1510第一次月考题,java第一阶段面向对象语法基础学习知识考试试题_第2页
达内jsd1510第一次月考题,java第一阶段面向对象语法基础学习知识考试试题_第3页
已阅读5页,还剩20页未读, 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、在线考试 本次考试得分: 100.0温馨提示:第七题BC答案都正确1.(单选)下列属于不合法Java标识符的是()。A. _memB. 12aC. M12D. $12正确答案: B2.(单选)程序的执行结果是:public class Test public static voidmain(String args) System.out.println(""+'a'+1); A. 98B. a1C. 971D. 197正确答案: B3.(单选)下列Java标识符,错误的是()A. _sys_varlB. $changeC. User_nameD. 1_fil

2、e 正确答案: D 4.(单选)请看下列代码: public String makinStrings() String s = "Fred" s = s + "47" s = s.substring(2, 5); s = s.toUpperCase(); return s.toString(); 调用 makinString 方法,得到的字符串长度是:A. 1B. 2C. 3D. 4正确答案: C5.(单选)分析如下代码,输出结果为()。public static voidmain(String args) int i = 0; boolean re =

3、 false; re = (+i) + i = 2) ? true : false; System.out.println("i=" + i + ",re="+re); A. i=1,re=trueB. i=0,re=trueC. i=1,re=falseD. i=0,re=false正确答案: A6.(单选)下列代码的运行结果是() public static void main(String args) String str = "420" str += 42; System.out.print(str); A. 42B. 420

4、C. 462D. 42042正确答案: D7.(单选)请看下列代码: public static void main(String args) 插入 代码 System.out.println(s); 如果程序输出的结果是 4247,那么 在 插入代码 处应该填入代码是()。A. String s = "123456789" s = (s-"123").replace(1,3,"24") - "89"B. StringBuffer s = new StringBuffer("123456789"

5、);s.delete(0,3).replace( 1,3, "24").delete(4,6);C. StringBuffer s = new StringBuffer("123456789"); s.delete(0,3).replace( 1,3, "24").delete(4,6);D. StringBuilder s = new StringBuilder("123456789");s.substring(3,6).delete( 1 ,2).insert( 1, "24");正确答案:

6、 B8.(单选)下列关于IDE开发环境Eclipse,说法错误的是:()。A. Eclipse可以通过插件(plugin)的方式扩展其功能。B. Eclipse联盟是由IBM公司捐资组建的。C. Eclipse使用了 SWT图形界面技术。D. Eclipse的运行不需要有JRE的支持。正确答案: D9.(单选)下列赋值语句中,正确的是() 。A. byte b1 = 10, b2 = 20; byte b=b1+b2;B. byte b1 = 10, b2 = 20; byte b=b1;C. byte b1 = 10, b2 = 20; byte b=b1>>1;D. byte

7、b1 = 10; byte b=+b1;正确答案: D10.(单选)运行下面的语句 : String s=""if(s=s+0) System.out.println("Hello World"); 编译,运行的结果 是:()。A. Hello WorldB. 无输出C编译错误D.抛出运行时异常 正确答案: B11. (单选)下列代码编译和运行的结果是:public static void main(String args) String elements = "for", "tea", "too&quo

8、t; ; Stringfirst = (elements.length > 0) ? elements0 : null; System.out.println(first); A. 编译出错B输出:teaC输出:forD.输出:null正确答案: C12.(单选 )下列表达式中,可以得到精确结果的是()A. double d1 = 3.0 - 2.6;B. double d4 = 2.5 * 1.5;C. double d2 = 30/300;D. double d3 = 1/2 + 0.5;正确答案: B13.(单选 )下列关于 JVM 说法,错误的是()。JVM 的内存大小。Java

9、字节码。A. JVM 通过专门的线程实现内存的回收。B. 使用java命令时,可以通过参数来设置分配C. JRE包括 JVM及Java核心类库。D. 目前主流版本JVM通过纯解释的方式运行正确答案: D 14.(单选)请看下列代码: interface Data public void load(); abstract class Info public abstract void load(); 下列选项中,能正确使用 Data 接口和 Info 类的是()。A. public class Employee extends Info implements Data public void l

10、oad() /*do something*/ B. public class Employee implements Info extends Data public void load() /*do something*/ C. public class Employee implements Info extends Data public void Data.load() /*d something */ public void load() /*do something */ D. public class Employee extends Info implements Data p

11、ublic void load() /*do something */ public void Info.load() /*do something*/ 正确答案: A15.(单选)下列数组声明语句中,错误的是:()。A. int arr = new int8;B. int arr = new int8;C. int arr = ;D. int arr = new int; 正确答案: B 16. (单选)运行下列代码: int oneArr = 2, 11, 26, 27, 37, 44, 48, 60 ; int twoArr = 19, 35, 49, 55, 58, 75, 83, 8

12、4, 91, 93 ; int threeArr = new intoneArr.length + twoArr.length; int p = 0, q = 0; while (p < oneArr.length && q < twoArr.length) threeArrp + q = oneArrp < twoArrq ? oneArrp+ : twoArrq+; if (p < oneArr.length) System.arraycopy(oneArr, p, threeArr, p + q, oneArr.length - p); else

13、if (q < twoArr.length) System.arraycopy(twoArr, q, threeArr, p + q, twoArr.length - q); System.out.println(Arrays.toString(threeArr); 输出的结果是: ()。A. 2,11,26,27,37,44,48,60,19,35,49,55,58,75,83,84,91,93;B. 2,11,19,26,27,35,37,44,48,49,55,58,60,75,83,84,91,93;C. 19,35,49,55,58,75,83,84,91,93,2,11,26

14、,27,37,44,48,60;D. 2,19,11,35,26,49,27,55,37,58,44,75,48,83,60,84,91,93; 正确答案: B17.(单选)程序的执行结果是: public class Test public static void main(String args) String str1 = new String("abc"); String str2 = new String("abc"); String str3 = str1;if(str1.equals(str2) System.out.println(&qu

15、ot;true"); else System.out.pr intln("false"); if(str1=str3) System.out.println("true"); else System.out.println(" false"); A. true trueB. true falseC. false trueD. false false正确答案: A18.(单选)运行下面的程序: String fileNames = "abc.txt", "bcd.exe", "

16、cde.exe", "def.dat","efg.exe" ; for (String fileName : fileNames) if (fileName.endsWith(".exe") System.out.print(fileName.substring(0,fileName .lastIndexOf(".exe")+" "); 控制台的输出结果是: ()A. bcd. cde. efg.B. bc cd efC. bcd.exe cde.exe efg.exeD. bcd c

17、de efg正确答案: D19.(单选)如下方法声明中,错误的是()。A. public void say() System.out.print(“Hi” ); B. public void say() System.out.print(“Hi” ); return; C. public int say() System.out.print(“Hi” ); return; D. public int say() System.out.print(“Hi” ); return 0; 正确答案: C 20.(单选)数据类型int、char和double所占用内存字节数分别是: ()。A. 4、 2

18、 和 8B. 2、 2 和 4C. 2、 1 和 8D. 4、 4 和 4正确答案: A21.(单选 )关于 String 和 StringBuffer 下面说法正确的是()。A. String 操作字符串不改变原有字符串的内容B. StringBuffer连接字符串速度没有 String快C. String可以使用append方法连接字符串D. StringBuffer 在 java.util 包中正确答案: A22.(单选 )运行下面的程序:int a = 100; int b = 200; a = a + b; b = a - b;a = a - b; System.out.printl

19、n("a=" + a + ", b=" + b); 输出的结果是: ()。A. a=100, b=300B. a=100, b=200C. a=200, b=100D. a=300, b=200正确答案: C23.(单选)下列代码的输出结果是: public class Yikes public static void go(Long n) System.out.println("Long"); public static void go(Short n) System.out.println("Short");

20、public static void go(int n) System.out.println("int"); public static void main(String args) short y = 6; long z = 7; go(y); go(z); A. Long LongB. Short LongC. int LongD. int int正确答案: C24.(单选)分析如下语句,说法错误的是()。A. break 可用于跳出循环,当多层嵌套时,只用于跳出一层循环B. break 即可以出现在循环语句中也可以出现在 switch 语句中C. continue

21、可以用于跳出循环D. continue 不能出现在 switch 语句中 正确答案: C(单选)A 类中有一个方法:protected int print(String str),B 类继承A类,以下方法能在B类中重写A类中print()方法的是:()。A. public int print(String str)B. private int print(String str)C. private void print(String str)D. public void print(String str)正确答案: A26.(单选)下列代码的运行结果是:String test = "

22、Test A. Test B. TestC. " String regex = ".s*" String result = test.split(regex); for (String s : result) System.out.print(s + " ");A. Test A Test B Test CB. Test A. Test B. Test C.C. Test . Test . Test .D. A. B. C.正确答案: A27.(单选 )请看下列代码 public class Member private Long userId

23、; private String nickName; / 以下是 getter 禾口 sett 方法 Main方法中的代码: Member m1=new Member(); m1.setUserId(newLong(100001); m1.setNickName("mick"); Member m2=newMember(); m2.setUserId(new Long(100001);m2.setNickName("mick"); System.out.println(m1=m2);System.out.println(m1.equals(m2); 控制

24、台的输出结果是:A. true falseB. false trueC. false falseD. true ture正确答案: C28.(单选)实现 Point 类的 equals 方法,具体逻辑为:“成员变量 x 和 y 分别相等的 Point 对象被视为相等”。 public class Point private int x; private int y; . public boolean equals(Object obj) 填入代码 插入代码处应填入的代码正确的是 :A. if(obj.x = this.x | obj.y = this.y) return true; retur

25、n false;B. if(obj.x = this.x && obj.y = this.y) return true; return false;C. if(!(obj instanceof Point) return false; if(Point)obj).x =(Point)obj).y && this.x = this.y) return true; return false;D. if(!(obj instanceof Point) return false; if(Point)obj).x = this.x && (Point)ob

26、j).y = this.y) return true; return false;正确答案: D29.(单选)运行下列代码,输出为 false 的是:()。A. String st1 = "abc" System.out.println("abc" = st1);B. String st2 = "abc" System.out.println(st2.equals(newString("abc");C. Integer i = 100; System.out.println(100 = i);D. ArrayLis

27、t list = new ArrayList();System.out.println(list.contains(null);正确答案: D30.(单选)请看下列代码,出现错误的行是:()public interfaceCookie Cookie cookie=new Cart ("小面包 ","盼盼"); public class Cart implements Cookie private String name; private String production; public Cart(String name,Stringproduction

28、) =name; duction=production; public void smell() cookie =new Cart(”蛋黄派","达利园"); A. 第2行B第4行C第11行D第12行正确答案: D31.(单选)请看下列代码的输出结果是:public class Bootchy int bootch; String snootch; public Bootchy() this("snootchy");System.out.print("first "); public Boo

29、tchy(String snootch) this(420, "snootchy"); System.out.print("second "); public Bootchy(int bootch, String snootch) this.bootch = bootch; this.snootch = snootch; System.out.print("third "); public static void main(String args) Bootchy b = new Bootchy(); System.out.print

30、(b.snootch + " " + b.bootch); A. first second third snootchy 420B. third second first snootchy 420C. third first second snootchy 420D. first second first third snootchy 420正确答案: B32.(单选)下列语句创建对象的总个数是: ()。 String s=”a”+”b” +”c”+”d”+”e”;A. 1B. 2C. 3D. 4正确答案: A33.(单选)下面的代码用于对数组 arr 实现冒泡排序: fo

31、r (int i = 0; i < arr.length - 1; i+) boolean isSwap = false; 空白处 if (!isSwap) break; 下列选项中,空白处可以填入的代码是:()。A. for (int j = arr.length - 1; j > i; j-) if (arrj < arrj - 1) int temp = arrj; arrj = arrj - 1; arrj - 1 = temp; isSwap = true; B. for (int j = arr.length - 1; j > 0; j-) if (arrj

32、 < arrj - 1) int temp = arrj; arrj = arrj - 1; arrj - 1 = temp; isSwap = true; C. for (int j = i + 1; j< arr.length; j+) if (arrj < arrj - 1) int temp = arrj; arrj = arrj - 1; arrj - 1 = temp; isSwap = true; D. for (int j = i; j< arr.length; j+) if (arrj < arrj - 1) int temp = arrj; a

33、rrj = arrj - 1; arrj - 1 = temp; isSwap = true; 正确答案: A34.(单选)请看下列代码: class Payload private int weight; public Payload(int wt) weight = wt; public Payload() public void setWeight(int w) weight = w; public String toString() return Integer.toString(weight); public class TestPayload static void changeP

34、ayload(Payload p) <插入代码 > public static void main(String args) Payload p = new Payload(); p.setWeight(1024); changePayload(p); System.out.println("The value of p is " + p); 假设运行后输出“ The value of p is 420”,那么 <插入代码 >处应 填入代码是:A. p.setWeight(420);B. Payload.setWeight(420);C. p = n

35、ew Payload(420);D. p = new Payload(); p.setWeight(420); 正确答案: A 35.(单选)下列代码运行的结果是 ()。 public class Base public static final String FOO = "foo" public static void main(String args) Base b = new Base(); Sub s = new Sub(); System.out.print(Base.FOO); System.out.print(Sub.FOO); System.out.prin

36、t(b.FOO); System.out.print(s.FOO); System.out.print(Base) s).FOO); class Sub extends Base public static final String FOO = "bar" A. foofoofoofoofooB. foobarfoobarbarC. foobarfoofoofooD. foobarfoobarfoo正确答案: D36.(多选)请看下列代码: public abstract class Shape int x; int y; public abstract void draw

37、(); public void setAnchor(int x, int y) this.x = x; this.y = y; 下列选项中能正确使用 Shape 类的是:A. public class Circle implements Shape private int radius; B. public abstract class Circle extends Shape private int radius; C. public class Circle extends Shape private int radius; public void draw(); D. public cl

38、ass Circle extends Shape private int radius; public void draw() /* code here */ 正确答案: BD37.侈选)在Java语言中,下列说法正确的是()。A. 个接口可以继承多个接口B. 个类可以继承多个类C一个类可以实现多个接口D. 个类可以有多个子类 正确答案: ACD38.(多选)请看下列代码: package com.tarena; public class Geodetics public static final double DIAMETER = 12756.32; 访问静态常量DIAMETER的方式正确的

39、是:A. import com.tarena.Geodetics; public class TerraCarta public double halfway() return Geodetics.DIAMETER/2.0; B. import com.tarena.Geodetics; public class TerraCarta public double halfway() return DIAMETER/2.0; C. import com.tarena; public class TerraCarta public double halfway() return Geodetics

40、.DIAMETER2/.0; D. import com.tarena.*; public class TerraCarta public double halfway() return Geodetics.DIAMETER2/.0; 正确答案: AD 39.(多选)请看下列代码 public class Foo public void method(String str,int age) 和 Foo 类中 method 方法重载的方法是 :A. public int method(String str,int age)B. public void method(String s,int ye

41、ar)C. public void method(int year,String s)D. public int method(int year,String s)正确答案: CD40.(多选)在<插入代码 >处,填入下列代码编译正确的是:public voidfoo(int x) < 插入代码 > A. foreach(int z : x) System.out.println(z);B. for(int z : x) System.out.println(z);C. while( x.hasNext() System.out.println( x.next();D.

42、 for( int i=0; i< x.length; i+ ) System.out.println(xi);正确答案: BD41.(多选)查看如下代码:class A protected int method (int a, int b) return 0; 下列选项中,可以在 A的子类中使用的是()。A. public int method (int a, int b) return 0; B. private int method(int a, int b) return 0; C. private int method(int a, long b) return 0; D. p

43、ublic short method(int a, int b) return 0; 正确答案: AC 42. (多选)题目代码的功能为:输出每个字符在一个字符串中出现的 次数 (不区分大小写 )。 String str = "ewrwqFrewqfsadfdsfdsfs" str=str.toLowerCase(); int max_length = 0; while (str.length() > 0) 插入代码 A. int length = str.length(); char first=str.charAt(0); String strNew = str.

44、replaceAll(String.valueOf(first), ""); if (length>strNew.length() max_length = length - strNew.length(); System.out.println(first+":"+max_length); B. int length = str.length(); char first=str.charAt(0); String strNew = str.replaceAll(String.valueOf(first), ""); if (l

45、ength>strNew.length() max_length = length - strNew.length(); str = strNew; System.out.println(first+":"+max_length); C. int length = str.length(); String first = str.substring(0, 1); String strNew = str.replaceAll(first, ""); if (length>strNew.length() max_length = length -

46、 strNew.length(); str = strNew; System.out.println(first+":"+max_length); D. int length = str.length(); String first = str.substring(0, 1); String strNew = str.replaceAll(first, ""); if (length>strNew.length() max_length = length - strNew.length();System.out.println(first+&quo

47、t;:"+max_length); 正确答案: BC 43.侈选)在Java语言中,下列说法正确的是:()。A. StringBuffer 和 StringBuilder 的区别在于: StringBuffer 是线程 安全的而 StringBuilder 不是。B. String是不可变对象,而StringBuffer中封装的字符串数据是 可以动态改变的。C判断两个StringBuilder对象的字符序列是否相同,可以调用其 equlas 方法进行比较。D.String的重写了 equals方法,重写的逻辑是:字符序列相同的String 对象 equals 方法返回 true。正确答案:ABD44.(多选 )下面的方法属于 StringBuffer 的是:()。A. sizeB. insertC. deleteD. length正确答案: BCD(多选)请看下列代码:public class Old public static Object get(Listlist) return list.get(0); 以下选项调用 get 方法,能编译通过的 是:A. Object o = Old.get(new LinkedList();B. Object o = Old.get(new LinkedList<?>();C. String s = Old.g

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论